Skip to content

Fix SonarCloud: Variable shadowing in tests and assertion improvements#2813

Merged
tastybento merged 2 commits intodevelopfrom
fix/sonar-pr3-shadowing-assertions
Mar 3, 2026
Merged

Fix SonarCloud: Variable shadowing in tests and assertion improvements#2813
tastybento merged 2 commits intodevelopfrom
fix/sonar-pr3-shadowing-assertions

Conversation

@tastybento
Copy link
Member

Summary

  • Fix ~80 variable shadowing issues in ~45 test classes (S1117). Removed duplicate field declarations when same as CommonTestSetup parent, renamed to distinct names when different.
  • Improve ~52 assertions: remove Boolean boxing (S5411), assertEqualsassertSame (S5785), swap reversed args (S3415), add comments to empty blocks (S108), extract assignments from sub-expressions (S3010), remove always-true/false conditions (S2589)

Risk

Low-Medium — verified each shadowed field's setUp() doesn't assign different values than the parent.

Test plan

  • ./gradlew clean test passes
  • SonarCloud re-scan confirms reduction

🤖 Generated with Claude Code

tastybento and others added 2 commits March 1, 2026 20:49
Fix ~132 SonarCloud Medium/Low severity issues:
- S1117/S2387: Resolve field shadowing in ~45 test classes. Remove duplicate
  field declarations when same as parent (CommonTestSetup), rename to distinct
  names when different (e.g., testIwm, testIsland, islandsManager)
- S5785: Replace assertEquals with assertSame for identity checks (~20 assertions)
- S5411: Remove unnecessary Boolean boxing (9 occurrences)
- S3010: Extract assignments from sub-expressions (4 occurrences)
- S2589: Remove @nonnull from informational annotations, keep null checks
- S108: Add comments to empty catch blocks
- S3415: Fix reversed assertEquals arguments
- S1130: Remove unnecessary throws clauses from test methods

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflicts between PR 3 variable shadowing fixes and
PRs 1/2/4 already merged into develop (eq() removal, commented
code deletion, @OverRide additions, parameterized tests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 3, 2026

@tastybento tastybento merged commit 86813cc into develop Mar 3, 2026
3 checks passed
@tastybento tastybento deleted the fix/sonar-pr3-shadowing-assertions branch March 3, 2026 05:14
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.

1 participant