Skip to content

Commit 019d717

Browse files
HandyS11claude
andauthored
refactor: SonarQube code-smell & duplication cleanup (#25)
* chore(sonar): exclude EF migrations and obj from analysis Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * style: apply analyzer auto-fixes (collection init, var, switch expr, UTF-8 literals) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor: extract repeated string literals into constants (S1192) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor: move Abstractions.Connections types to matching namespace (IDE0130) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor(localization): extract shared RustPlusBot.Localization (ILocalizer + 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> * refactor(workspace): collapse channel locators onto shared CachingChannelLocator Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor(discord): extract shared poster boilerplate into DiscordChannelMessenger Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor: bundle cohesive dependencies to satisfy S107 parameter limit Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor: extract helpers to reduce cognitive complexity below 15 (S3776) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0ea3724 commit 019d717

150 files changed

Lines changed: 1132 additions & 1337 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/Sonar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
- name: Build and analyze
6262
run: |
63-
./.sonar/scanner/dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.coverage.exclusions="**/tests/**" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
63+
./.sonar/scanner/dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.coverage.exclusions="**/tests/**" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.cpd.exclusions="**/Migrations/*.cs" /d:sonar.exclusions="**/Migrations/*.cs,**/obj/**,**/bin/**"
6464
dotnet build --no-restore --configuration Release
6565
dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage;Format=opencover" --blame-hang-timeout 60s
6666
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.9" />
1111
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.9" />
1212
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.9" />
13+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.9" />
1314
<PackageVersion Include="Persistord.Core" Version="1.0.0-beta.1" />
1415
<PackageVersion Include="RustPlusApi" Version="2.0.0-beta.3" />
1516
<PackageVersion Include="RustPlusApi.Fcm" Version="2.0.0-beta.3" />

RustPlusBot.slnx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<Project Path="src/RustPlusBot.Features.Players/RustPlusBot.Features.Players.csproj" />
1515
<Project Path="src/RustPlusBot.Features.Switches/RustPlusBot.Features.Switches.csproj" />
1616
<Project Path="src/RustPlusBot.Features.Workspace/RustPlusBot.Features.Workspace.csproj" />
17+
<Project Path="src/RustPlusBot.Localization/RustPlusBot.Localization.csproj" />
1718
<Project Path="src/RustPlusBot.Persistence/RustPlusBot.Persistence.csproj" />
1819
</Folder>
1920
<Folder Name="/tests/">
@@ -28,6 +29,7 @@
2829
<Project Path="tests/RustPlusBot.Features.Alarms.Tests/RustPlusBot.Features.Alarms.Tests.csproj" />
2930
<Project Path="tests/RustPlusBot.Features.Chat.Tests/RustPlusBot.Features.Chat.Tests.csproj" />
3031
<Project Path="tests/RustPlusBot.Features.Events.Tests/RustPlusBot.Features.Events.Tests.csproj" />
32+
<Project Path="tests/RustPlusBot.Localization.Tests/RustPlusBot.Localization.Tests.csproj" />
3133
<Project Path="tests/RustPlusBot.Persistence.Tests/RustPlusBot.Persistence.Tests.csproj" />
3234
</Folder>
3335
</Solution>

src/RustPlusBot.Abstractions/Connections/IRustServerQuery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace RustPlusBot.Features.Connections.Listening;
1+
namespace RustPlusBot.Abstractions.Connections;
22

33
/// <summary>Reads live data from a connected server's socket (implemented by the connection supervisor).</summary>
44
public interface IRustServerQuery

src/RustPlusBot.Abstractions/Connections/MapDimensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace RustPlusBot.Features.Connections.Listening;
1+
namespace RustPlusBot.Abstractions.Connections;
22

33
/// <summary>The static-per-wipe map size needed to convert world coordinates to a grid reference.</summary>
44
/// <param name="Width">Map image width.</param>

src/RustPlusBot.Abstractions/Connections/MapMarkerSnapshot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace RustPlusBot.Features.Connections.Listening;
1+
namespace RustPlusBot.Abstractions.Connections;
22

33
/// <summary>One map marker observed in a <c>GetMapMarkers</c> poll.</summary>
44
/// <param name="Id">The stable marker id (used to diff polls).</param>

src/RustPlusBot.Abstractions/Connections/MarkerKind.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace RustPlusBot.Features.Connections.Listening;
1+
namespace RustPlusBot.Abstractions.Connections;
22

33
/// <summary>The subset of Rust map-marker types this bot reasons about; everything else is <see cref="Other"/>.</summary>
44
public enum MarkerKind

src/RustPlusBot.Abstractions/Connections/MonumentSnapshot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace RustPlusBot.Features.Connections.Listening;
1+
namespace RustPlusBot.Abstractions.Connections;
22

33
/// <summary>One named monument observed in a <c>GetMap</c> response.</summary>
44
/// <param name="Token">The monument token (e.g. <c>oilrig_1</c>, <c>large_oil_rig</c>).</param>

src/RustPlusBot.Abstractions/Connections/ServerInfoSnapshot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace RustPlusBot.Features.Connections.Listening;
1+
namespace RustPlusBot.Abstractions.Connections;
22

33
/// <summary>A point-in-time view of a server's population and wipe, decoupled from RustPlusApi types.</summary>
44
/// <param name="Players">Current player count.</param>

src/RustPlusBot.Abstractions/Connections/ServerTimeSnapshot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace RustPlusBot.Features.Connections.Listening;
1+
namespace RustPlusBot.Abstractions.Connections;
22

33
/// <summary>A point-in-time view of in-game time, decoupled from RustPlusApi types.</summary>
44
/// <param name="TimeOfDay">Current in-game time of day (RustPlusApi <c>TimeInfo.Time</c>).</param>

0 commit comments

Comments
 (0)