refactor: SonarQube code-smell & duplication cleanup#25
Open
HandyS11 wants to merge 9 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…UTF-8 literals) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…IDE0130) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…alizer + DictionaryLocalizer) Collapses 6 byte-identical per-feature localizer implementations into one shared DictionaryLocalizer + ILocalizer in a new leaf project. The 6 per-feature interfaces are kept as thin markers extending the shared ILocalizer, and each feature keeps a 1-line concrete localizer that subclasses DictionaryLocalizer and implements its marker — so DI registrations and ~30 consumers are unchanged and there is no last-wins DI collision in the composed host container. Resolves the in-code 'consolidate into a shared project' TODO. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nnelLocator Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nelMessenger Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…776) Co-Authored-By: Claude Opus 4.8 <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.
Cleans up the SonarQube maintainability smells (82) and the structural duplication (8.4% density, 1,551 lines), sequenced low-risk → high-risk with the test suite green at every commit.
What changed
Mechanical:
chore(sonar): exclude auto-generated EF migrations +obj/binfrom analysis (CPD noise).style: analyzer auto-fixes (collection init,var, switch expr, UTF-8 literals). Two fixes deliberately left as-is where they conflict with other analyzers (nested-ternaryS3358, primary-ctorCA2000).S1192: extracted repeated string literals toprivate const.IDE0130: moved 8RustPlusBot.Abstractions.Connectionstypes to the namespace matching their folder, updating ~69 consumers (the sharedusingwas kept where genuineFeatures.Connections.Listeningtypes are still referenced).Structural (the duplication):
RustPlusBot.Localization(new project): sharedILocalizer+DictionaryLocalizerreplace 6 byte-identical per-feature localizer implementations. The 6IXLocalizerinterfaces are kept as thin markers extending the shared one, so per-feature DI registrations stay distinct (no last-wins collision). Resolves the in-code "consolidate into a shared project" TODO.CachingChannelLocator: abstract base + 5 sealed subclasses collapse the near-identical Event/Map/Switch/Alarm/TeamChat locators (each was ~75 lines → ~10).DiscordChannelMessenger: shared post/edit boilerplate for 4 posters (Switch/Alarm self-healEnsureAsync, Event/Player fire-and-forgetPostAsync). The Map poster (posts a file) and Alarm'sSendEveryonePingAsyncare intentionally left separate.Other smells:
S107: bundled cohesive constructor dependencies intorecordtypes on 6 ctors + 1 method (all now ≤7 params).S3776: extracted helpers to drop cognitive complexity <15 inMapRenderer.DrawPlayers,ServerInfoMessageRenderer.RenderAsync,ConnectionSupervisor.RunConnectedAsync.Notes for review
dotnet jb cleanupcode --profile=ReformatAndReorderproduces zero diff (format gate passes).ResolveAsyncmoved from an O(1) dedicated reverse-dict to an O(n) scan of the forward map — equivalent under the data model (a channel can't map to two server keys), negligible volume.{MessageId}/{ChannelId}were bound to swapped values (human-readable message unchanged).develop— Community-Edition Sonar analyzes the single long-lived branch only.🤖 Generated with Claude Code