SONARJAVA-6842: Implement S9364: Local variables should not span switch case groups - #6019
Conversation
Prevent local variable declarations from coupling distinct switch case groups.
Lock secondary messages and nested-switch duplicate suppression.
This comment has been minimized.
This comment has been minimized.
CI rejected compound assignments that can execute before their variables are initialized. Use definite assignments for those cross-group accesses and correct the nested-switch secondary offset flagged in review.
Code Review ✅ Approved 1 resolved / 1 findingsImplements rule S9364 to detect local variables spanning colon-style switch case groups, addressing the wrong secondary offset for 'outer' in the nested switch test. No issues found. ✅ 1 resolved✅ Bug: Wrong secondary offset for 'outer' in nested switch test
Implementation Status ✅ 2 of 2 objectives covered✅ SONARJAVA-6842 - 2 of 2 objectives coveredThis PR implements rule S9364 to report local variable declarations in colon-style switch statements and expressions when accessed from later distinct case groups, using the declaration identifier as the primary location and the first access in each later case group as a secondary location with the specified message. ✅ 2 covered here
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 |
|




Summary
Links
Test plan
mvn -pl java-checks -am test -Dtest=LocalVariablesShouldNotSpanSwitchCaseGroupsCheckTest -Dsurefire.failIfNoSpecifiedTests=falseAI disclosure