[java] New rule: UnnecessaryBlock#6639
Conversation
|
Compared to main: (comment created at 2026-05-08 14:03:19+00:00 for 8bdd308) |
Co-authored-by: Clément Fournier <clem.fournier@proton.me>
|
Sometimes copy-paste errors can create which might make sense to also catch (i.e. if parent size is 1, report it without checking for variable definitions). The Spring regressions show another usecase where blocks are used to limit scope of anonymous classes -- should that be acceptable? |
|
Thanks. Adding checks for the I did look at the spring framework regression reports... and completely missed the |
If it's not a violation, the method should not be called "bad", but "good"
adangel
left a comment
There was a problem hiding this comment.
Thanks!
The functionality looks good, we need to improve the docs.
…style/UnnecessaryBlockRule.java Co-authored-by: Andreas Dangel <andreas.dangel@adangel.org>
Co-authored-by: Andreas Dangel <andreas.dangel@adangel.org>
Describe the PR
New rule that flags unnecessary blocks. A block is necessary if it is the body of a method/control structure etc., or if it is used to restrict the scope of a variable. All other blocks are deemed unnecessary.
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)