Skip to content

chore(sonar): clean unused imports, suppressions, and private members#58

Merged
aksOps merged 1 commit into
mainfrom
chore/sonar-cleanup
Apr 23, 2026
Merged

chore(sonar): clean unused imports, suppressions, and private members#58
aksOps merged 1 commit into
mainfrom
chore/sonar-cleanup

Conversation

@aksOps

@aksOps aksOps commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Mechanical SonarCloud maintainability cleanup targeting "Maintainability on New Code" rating A. Zero behavior change.

Edit categories (counts)

  • Unused imports removed: 89 (across 55 files)
  • Unnecessary @SuppressWarnings(\"unchecked\") removed: 39 (net; originally 186, now 147)
  • Unused private static final fields removed: 5
    • JpaEntityDetector.ENTITY_RE (pattern never referenced)
    • SpringRestDetector.PROP_REQUESTMAPPING
    • GraphqlResolverDetector.BATCH_MAPPING_RE
    • SequelizeORMDetector.MODEL_INIT_RE
    • CSharpStructuresDetector.API_CONTROLLER_RE
  • Unused private methods removed: 4
    • McpToolsTest.parseJsonArray
    • GraphStoreTest.mockEmptyResult
    • GraphStoreExtendedTest.mockEmptyResult
    • StructuredParserTest.getData
    • (plus AbstractAntlrDetectorHelperTest.exposedOriginalTextOf on a private static final inner class)
  • Unused local variables removed: 6 (the guard/middleware/topic/queue/event/messageQueue locals in QueryServiceTest.findDeadCodeShouldNotFlagMessageDrivenComponents — replaced with a comment explaining the intent)

Verification

  • mvn -B compile clean
  • mvn -B test-compile clean (only 6 pre-existing unchecked warnings remain — all on pre-existing code paths not touched by this PR)
  • mvn -B test3278 tests run, 0 failures, 0 errors, 31 skipped (~51s)

Skipped / noteworthy

  • QueryServiceTest.java: kept the @SuppressWarnings(\"unchecked\") preceding ArgumentCaptor.forClass(List.class) casts. The task description noted the unchecked cast warning could be a real fix (typed variable) but fixing it would require actual behavior change (switching to typed captors is non-mechanical). Left as-is per task rules.
  • StatsServiceTest.java / TopologyServiceTest.java / GraphStoreTopologyAndStatsTest.java / GraphStoreAggregateStatsTest.java: conservatively left suppressions in place. The heuristic detected they could be removed, but trial removal surfaced new warnings — Mockito ArgumentCaptor.forClass(List.class) and captor.capture() patterns emit unchecked warnings on call sites not covered by the local @SuppressWarnings, and removing the suppression triggers method-invocation unchecked warnings. Left alone.
  • AbstractAntlrDetectorHelperTest.exposedOriginalTextOf: method was on a private static final inner class — effectively file-private. Removed along with now-unreachable helper.
  • No @Autowired / @Value / @ConfigurationProperties / @Inject / @Mock / @Spy / @InjectMocks / picocli / @EventListener fields were touched. Detector classes under src/main/java/io/github/randomcodespace/iq/detector/ remain in place (only unused private fields inside them were trimmed).

Test plan

  • mvn -B compile clean
  • mvn -B test-compile clean (no new warnings introduced)
  • mvn -B test — 3278/3278 passing

Generated with Claude Code

Mechanical cleanup to drop SonarCloud code smells:
- 89 unused imports removed across 55 files
- 5 unused private static final fields removed (regex patterns never referenced)
- 4 unused private methods removed
- 6 unused local variables removed
- 39 unnecessary @SuppressWarnings("unchecked") annotations removed

Zero behavior change. All 3278 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@aksOps aksOps merged commit eaea1ff into main Apr 23, 2026
9 checks passed
@aksOps aksOps deleted the chore/sonar-cleanup branch April 26, 2026 05:52
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