checkstyle / checkstyle/checkstyle
new check : PreferExpressionLambda
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 4.2k
- Avg merge
- 20h 33m
- Merged PRs (30d)
- 234
Description
Similar to Intellij Inspection.
Description : Reports lambda expressions with code block bodies when expression-style bodies can be used
```
/var/tmp $ cat config.xml
/var/tmp $ cat Test.java
public class Test {
Runnable oneLineValid = () -> System.out.println("Hello"); // No Violation
Runnable oneLineInvalid = () -> { // Violation
System.out.println("Hello world");
};
Runnable longValid = () -> { // No Violation
System.out.println("Hello world");
System.out.println("Hello world2");
};
}
```
Contributor guide
Research direction
Start by reproducing the examples from config.xml and Test.java, comparing the valid and invalid lambda forms shown in the issue. Read the existing Checkstyle checks and their tests to determine the expected check structure and configuration name. Done means the new check identifies expression-style lambda opportunities without flagging multi-statement bodies, with coverage for the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100