Skip to content

SONARJAVA-6431 Centralize Tree.Kind assignments - #5886

Merged
aurelien-coet-sonarsource merged 2 commits into
masterfrom
ac/SONARJAVA-6431
Aug 6, 2026
Merged

SONARJAVA-6431 Centralize Tree.Kind assignments#5886
aurelien-coet-sonarsource merged 2 commits into
masterfrom
ac/SONARJAVA-6431

Conversation

@aurelien-coet-sonarsource

@aurelien-coet-sonarsource aurelien-coet-sonarsource commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • API enhancements:
    • Added centralized lists CLASS_KINDS and ASSIGNMENT_KINDS to Tree.Kind for cleaner visitor node registration.
  • Refactoring:
    • Replaced explicit lists of class-like and assignment kinds across Java checks and frontend visitors with the new centralized constants.

This will update automatically on new commits.

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

SONARJAVA-6431

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅, but I believe the base branch needs to be ac/SONARJAVA-6430

@sonarqube-next

sonarqube-next Bot commented Aug 6, 2026

Copy link
Copy Markdown

@aurelien-coet-sonarsource
aurelien-coet-sonarsource merged commit 98a7df7 into master Aug 6, 2026
16 checks passed
@aurelien-coet-sonarsource
aurelien-coet-sonarsource deleted the ac/SONARJAVA-6431 branch August 6, 2026 13:07
@gitar-bot

gitar-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Centralizes assignment and class kind lists in Tree.Kind and updates Java checks and visitors to use them. Consider updating ExpressionComplexityCheck to appropriately scope enum and interface bodies alongside the new complexity-reset boundaries.

✅ 1 resolved
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.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants