Fix SonarCloud: Variable shadowing in tests and assertion improvements#2813
Merged
tastybento merged 2 commits intodevelopfrom Mar 3, 2026
Merged
Fix SonarCloud: Variable shadowing in tests and assertion improvements#2813tastybento merged 2 commits intodevelopfrom
tastybento merged 2 commits intodevelopfrom
Conversation
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>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
CommonTestSetupparent, renamed to distinct names when different.assertEquals→assertSame(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 testpasses🤖 Generated with Claude Code