Skip to content

Fix Sonar code quality issues: S5361, S3776 complexity#2825

Merged
tastybento merged 3 commits intodevelopfrom
worktree-curried-gliding-stallman
Mar 4, 2026
Merged

Fix Sonar code quality issues: S5361, S3776 complexity#2825
tastybento merged 3 commits intodevelopfrom
worktree-curried-gliding-stallman

Conversation

@tastybento
Copy link
Member

Summary

  • Addon.java: Replace replaceAll("/", Matcher.quoteReplacement(...)) with replace("/", File.separator) (S5361 — prefer String#replace over String#replaceAll for literal substitution); remove the now-unused Matcher import.
  • AdminTeleportUserCommand: Simplify args.isEmpty() || args.size() == 1args.size() < 2 to eliminate the || operator and bring canExecute cognitive complexity down to 15 (S3776).
  • AdminPurgeRegionsCommand: Extract private helper methods from three over-complex methods to bring each within the 15-point cognitive complexity limit (S3776):
    • deletePlayerFromWorldFolder (29 → ~3): maybeDeletePlayerData, resolveLastLogin, deletePlayerFiles, deletePlayerFile
    • deleteRegionFiles (~24 → ~7): isFileFresh, isAnyDimensionFresh, deleteOneRegion
    • findOldRegions (~30 → ~5): logRegionFolderPaths, collectCandidateNames, addFileNames, parseRegionCoords

Also includes JUnit tests for BlueprintsManager (35 tests).

Test plan

  • ./gradlew compileJava passes
  • AdminPurgeRegionsCommandTest passes
  • BlueprintsManagerTest (35 tests) passes

🤖 Generated with Claude Code

tastybento and others added 3 commits March 3, 2026 21:35
35 tests covering constructor, blueprint/bundle CRUD, validation,
permission checks, file I/O (load/save/delete/rename), and paste error paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Addon.java: replace replaceAll() with replace() for literal string
  substitution (S5361); remove now-unused Matcher import
- AdminTeleportUserCommand: simplify first guard to args.size() < 2
  to drop the || operator and reduce cognitive complexity to 15 (S3776)
- AdminPurgeRegionsCommand: refactor deletePlayerFromWorldFolder,
  deleteRegionFiles, and findOldRegions by extracting private helper
  methods (maybeDeletePlayerData, resolveLastLogin, deletePlayerFiles,
  deletePlayerFile, isFileFresh, isAnyDimensionFresh, deleteOneRegion,
  logRegionFolderPaths, collectCandidateNames, addFileNames,
  parseRegionCoords) to reduce cognitive complexity to within limits (S3776)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AdminPurgeRegionsCommand:
- Remove unused OfflinePlayer import
- Introduce DimFolders record to reduce deleteOneRegion from 10 to 4
  parameters (S107 - too many parameters)
- Replace & with && and extract operands to variables for the overworld
  deletion chain (S2178 - non-short-circuit operators on booleans)

BlueprintsManagerTest:
- Remove public modifier from class declaration and all @test methods
  (S5786 - JUnit 5 test classes/methods need not be public)

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

sonarqubecloud bot commented Mar 4, 2026

@tastybento tastybento merged commit 9c1351d into develop Mar 4, 2026
3 checks passed
@tastybento tastybento deleted the worktree-curried-gliding-stallman branch March 4, 2026 06:02
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