SONARJAVA-6431 Centralize Tree.Kind assignments - #5886
SONARJAVA-6431 Centralize Tree.Kind assignments#5886aurelien-coet-sonarsource wants to merge 6 commits into
Conversation
| return Arrays.asList( | ||
| Tree.Kind.CLASS, | ||
| Tree.Kind.RECORD, | ||
| return ListUtils.concat(Tree.Kind.CLASS_KINDS, Tree.Kind.ASSIGNMENT_KINDS, List.of( |
There was a problem hiding this comment.
💡 Bug: ExpressionComplexityCheck now scopes enum/interface bodies
Previously nodesToVisit() and the visitNode/leaveNode/isInsideEquals branches only treated CLASS and RECORD as complexity-reset boundaries; switching to Tree.Kind.CLASS_KINDS additionally treats ENUM, INTERFACE, ANNOTATION_TYPE and IMPLICIT_CLASS as boundaries that push/pop a fresh count/level scope. This changes how S1067 counts operators for expressions inside enum/interface/annotation bodies, so reported issues may differ, yet no test accompanies this behavior change (unlike RedundantNullabilityAnnotationsCheck). Confirm the new scoping is intended and add a test covering an expression inside an enum/interface, or restrict this check to the previous CLASS/RECORD set if the broadening is unintended.
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsCentralizes class-like and assignment kinds into Tree.Kind and updates Java checks and frontend visitors to use them. ExpressionComplexityCheck now scopes enum and interface bodies alongside CLASS and RECORD. 💡 Bug: ExpressionComplexityCheck now scopes enum/interface bodies📄 java-checks/src/main/java/org/sonar/java/checks/ExpressionComplexityCheck.java:58 📄 java-checks/src/main/java/org/sonar/java/checks/ExpressionComplexityCheck.java:111 📄 java-checks/src/main/java/org/sonar/java/checks/ExpressionComplexityCheck.java:124 📄 java-checks/src/main/java/org/sonar/java/checks/ExpressionComplexityCheck.java:143 Previously nodesToVisit() and the visitNode/leaveNode/isInsideEquals branches only treated CLASS and RECORD as complexity-reset boundaries; switching to Tree.Kind.CLASS_KINDS additionally treats ENUM, INTERFACE, ANNOTATION_TYPE and IMPLICIT_CLASS as boundaries that push/pop a fresh count/level scope. This changes how S1067 counts operators for expressions inside enum/interface/annotation bodies, so reported issues may differ, yet no test accompanies this behavior change (unlike RedundantNullabilityAnnotationsCheck). Confirm the new scoping is intended and add a test covering an expression inside an enum/interface, or restrict this check to the previous CLASS/RECORD set if the broadening is unintended. 🤖 Prompt for agentsOptionsAuto-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 |
|
mostafa-mohammed-sonarsource
left a comment
There was a problem hiding this comment.
✅, but I believe the base branch needs to be ac/SONARJAVA-6430




Summary by Gitar
CLASS_KINDSandASSIGNMENT_KINDStoTree.Kindfor cleaner visitor node registration.This will update automatically on new commits.