Skip to content

fix: resolve S3267 and a batch of test-project SonarCloud issues#4991

Merged
arturcic merged 3 commits into
GitTools:mainfrom
arturcic:fix/sonar-s3267-repositorystore
Jun 29, 2026
Merged

fix: resolve S3267 and a batch of test-project SonarCloud issues#4991
arturcic merged 3 commits into
GitTools:mainfrom
arturcic:fix/sonar-s3267-repositorystore

Conversation

@arturcic

@arturcic arturcic commented Jun 29, 2026

Copy link
Copy Markdown
Member

Follow-up SonarCloud cleanup after #4990: a production fix plus a batch of test-project findings. Code fixes here; analyzer false-positives were dispositioned on SonarCloud.

Production (GitVersion.Core)

  • S3267 ×2 (RepositoryStore.GetCommitBranches) — foreach+if simplified to Any(...) / Where(returnedBranches.Add)

Test projects

  • S6580 ×16 — pass CultureInfo.InvariantCulture to DateTimeOffset.Parse
  • S3260 ×3 — seal private test helper classes (MockBuildAgent, BuildAgent, MockCommit)
  • S1450 ×2 — localise single-method fields (DroneTests.sp, GitVersionTaskDirectoryTests.gitDirectory)
  • S1118protected constructor on TestBase
  • S1104 / S3881 — encapsulate GitVersionContextBuilder.ServicesProvider as a property; seal the class + simple sealed-disposable pattern
  • S3400ExecutableHelper.GetDotNetExecutable()const
  • S1186 — remove empty DynamicRepositoryTests teardown
  • S6562DateTimeKind.Utc in CommitDateTests
  • S6610 — char EndsWith overload in DateFormatterTests

Dispositioned on SonarCloud (not code)

  • False PositiveMockEngine/MockTaskItem S2325 ×5 (interface implementations can't be static); BuildServerBaseTests S1172 ×2 (override params can't be removed); MergeMessageBaseVersionStrategyTests S2259 (guarded by Shouldly ShouldNotBeNull); GenerateGitVersionInformationTest S3241 (callers do chain off the return)

Verification

  • dotnet build ./src/GitVersion.slnx — 0 warnings / 0 errors
  • dotnet format --verify-no-changes — clean
  • Tests green: BuildAgents 276, App 663, MsBuild 453, Output 369, Configuration 273, and the touched Core fixtures 75/75

🤖 Generated with Claude Code

arturcic and others added 2 commits June 29, 2026 21:46
- Collapse the inner commit-scan foreach+if to Any() (removes item when a matching
  commit exists; also avoids repeated Remove calls)
- Replace the fallback branch-grouping foreach+if with Where(returnedBranches.Add)

Behaviour-preserving.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add CultureInfo.InvariantCulture to the 16 DateTimeOffset.Parse calls across the test
projects (VariableProviderTests, BuildAgents.Tests agents, WixFileTests), and import
System.Globalization where missing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@arturcic
arturcic force-pushed the fix/sonar-s3267-repositorystore branch from 7f194ef to be0c632 Compare June 29, 2026 19:46
- S3260: seal private test helper classes (MockBuildAgent, BuildAgent, MockCommit)
- S1450: localise single-method fields (DroneTests.sp, GitVersionTaskDirectoryTests.gitDirectory)
- S1118: protected constructor on TestBase
- S1104/S3881: encapsulate GitVersionContextBuilder.ServicesProvider as a property and
  seal the class with the simple sealed-disposable pattern
- S3400: replace ExecutableHelper.GetDotNetExecutable() with a const
- S1186: remove empty DynamicRepositoryTests teardown
- S6562: pass DateTimeKind.Utc in CommitDateTests
- S6610: use the char EndsWith overload in DateFormatterTests

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@arturcic arturcic changed the title fix: resolve post-merge SonarCloud findings (S3267, S6580) fix: resolve S3267 and a batch of test-project SonarCloud issues Jun 29, 2026
@arturcic
arturcic merged commit d84944e into GitTools:main Jun 29, 2026
214 of 215 checks passed
@arturcic
arturcic deleted the fix/sonar-s3267-repositorystore branch June 29, 2026 20:38
@mergify

mergify Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Thank you @arturcic for your contribution!

@sonarqubecloud

Copy link
Copy Markdown

@arturcic arturcic modified the milestones: 6.x, 6.8.0 Jun 30, 2026
@arturcic

Copy link
Copy Markdown
Member Author

🎉 This issue has been resolved in version 6.8.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant