SONARJAVA-6613 Implement new rule S9021#5784
Conversation
This rule detects Spring @configuration classes declared with the 'final' modifier, which prevents Spring from creating CGLIB proxies necessary for proper bean lifecycle management and singleton enforcement.
4ba1571 to
26003e4
Compare
…Check by replacing invalid Tree.Kind.MODIFIER with ModifiersUtils.findModifier()
- Removed `public` modifier from top-level classes in ConfigurationClassShouldNotBeFinalCheckSample.java to fix Java compilation error (multiple public classes in a single file) - Removed `public` access modifier from top-level classes in ConfigurationClassShouldNotBeFinalCheckSample.java to fix compilation error caused by multiple public classes in a single file.
…ClassShouldNotBeFinalCheckSample.java that pointed to column 8 (position of old 'public' modifier) after 'public' was removed and 'final' moved to column 1
Add explicit documentation and test case clarifying that S9021 intentionally only detects direct @configuration annotations, not meta-annotations like @SpringBootApplication. This design decision avoids complexity with checking proxyBeanMethods on composed annotations. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code Review ✅ Approved 1 resolved / 1 findingsImplements rule S9021 to detect final ✅ 1 resolved✅ Edge Case: @configuration detected only as direct annotation, not meta-annotation
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
1 similar comment
Code Review ✅ Approved 1 resolved / 1 findingsImplements rule S9021 to detect final ✅ 1 resolved✅ Edge Case: @configuration detected only as direct annotation, not meta-annotation
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




This rule detects Spring @configuration classes declared with the 'final' modifier, which prevents Spring from creating CGLIB proxies necessary for proper bean lifecycle management and singleton enforcement.