Skip to content

SONARJAVA-6863 Remove continue statements - #6046

Merged
romainbrenguier merged 2 commits into
masterfrom
romain/fix-qg
Aug 27, 2026
Merged

SONARJAVA-6863 Remove continue statements#6046
romainbrenguier merged 2 commits into
masterfrom
romain/fix-qg

Conversation

@romainbrenguier

Copy link
Copy Markdown
Contributor

Reported by Sonar S6916

Part of RC-73

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Replace "if" statement with pattern match guard SONARJAVA-6863 Replace "if" statement with pattern match guard Aug 27, 2026
@hashicorp-vault-sonar-prod

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

Copy link
Copy Markdown
Contributor

SONARJAVA-6863

@datadog-sonarsource

datadog-sonarsource Bot commented Aug 27, 2026

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 11bd08e | Docs | View more details | Give us feedback!

gitar-bot[bot]

This comment was marked as resolved.

Replace continue statements with inverted conditions in
HashCodeMismatchedFieldsCheck and LocalVariablesShouldNotSpanSwitchCaseGroupsCheck.
Revert the pattern match guard in CompilationOrPreparationInLoopCheck
which used an unsupported "when" syntax, restoring the original "if" statement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gitar-bot
gitar-bot Bot dismissed their stale review August 27, 2026 11:57

✅ All code review findings resolved.

Configure merge blocking

@gitar-bot

gitar-bot Bot commented Aug 27, 2026

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

Refactors the codebase to use pattern match guards in place of if statements, addressing the guard on enum constant case labels does not compile finding. No issues found.

✅ 1 resolved
Bug: Guard on enum constant case labels does not compile

📄 java-checks/src/main/java/org/sonar/java/checks/CompilationOrPreparationInLoopCheck.java:202-210
A when guard is only permitted on pattern (and null) case labels; case POSTFIX_INCREMENT, POSTFIX_DECREMENT, PREFIX_INCREMENT, PREFIX_DECREMENT when ... uses constant labels, so javac rejects it (: or -> expected / not a statement / ';' expected) — reproduced with both JDK 21 (the project's jdk.min.version) and JDK 26. The module no longer compiles, breaking the whole build. Either keep the nested if, or drop the switch and express the check as a single condition.

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

@romainbrenguier romainbrenguier changed the title SONARJAVA-6863 Replace "if" statement with pattern match guard SONARJAVA-6863 Remove continue statements Aug 27, 2026
@romainbrenguier
romainbrenguier enabled auto-merge (squash) August 27, 2026 12:30
@sonarqube-next

Copy link
Copy Markdown
Contributor

@romainbrenguier
romainbrenguier merged commit e690a11 into master Aug 27, 2026
28 of 29 checks passed
@romainbrenguier
romainbrenguier deleted the romain/fix-qg branch August 27, 2026 12:37
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