checkstyle / checkstyle/checkstyle
Wrong indentation warning for single parameter lambdas without braces in try…catch blocks
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 4.2k
- Avg merge
- 22h 23m
- Merged PRs (30d)
- 232
Description
this code:
``` java
return Files.find(folder, Integer.MAX_VALUE, (path, fileOpts) -> "pom.xml".equals(path.getFileName()))
.map(pomXml -> folder.getParent().relativize(pomXml));
```
Produces the warning
> lambda bei Einrücktiefe 16 nicht an korrekter Einrücktiefe 17
(Rough translation: “Expected lambda at indentation level 16 to be at indentation level 17”)
However, this code does not:
``` java
return Files.find(folder, Integer.MAX_VALUE, (path, fileOpts) -> "pom.xml".equals(path.getFileName()))
.map((pomXml) -> folder.getParent().relativize(pomXml));
```
The code is correctly indented for my configuration, so I’d expect not to see a warning in both cases.
I could observe this behaviour at other places, too. Adding braces around the lambda parameter always fixed the warning.
My indentation configuration:
``` xml
```
##
Contributor guide
Research direction
No source file or test is named in the issue. Start by reproducing the warning with the two Java lambda examples and the shown Indentation configuration, then trace the indentation check for lambdas in try-catch contexts. Done means equivalent correctly indented lambdas produce no warning, including the single-parameter form without braces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100