Skip to content

fix: resolve sonar issues - #1183

Merged
vbreuss merged 2 commits into
mainfrom
fix/sonar-issues
Nov 2, 2026
Merged

vbreuss merged 2 commits into
mainfrom
fix/sonar-issues

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 2, 2026

Copy link
Copy Markdown
Member

Resolves the open SonarCloud issues and replaces the accepted ones that are intentional or false positives with in-code suppressions, so the reason is visible next to the code instead of only in SonarCloud.

Fixed

  • Since .NET 11 the BCL offers char overloads of StartsWith, EndsWith, IndexOf and LastIndexOf with a StringComparison parameter, so the char-only calls are flagged. They now pass StringComparison.Ordinal, and the missing IndexOf(char, int, StringComparison) polyfill is added for older frameworks.
  • The EndsWith(char) polyfill in the compression package is no longer used and is removed.
  • The NextInt64 overloads in IRandom and RandomWrapper are adjacent (reordering only, no API change).
  • Smaller cleanups: HasFlag instead of a bitwise check, a merged nested if, a nested ternary in ExceptionFactory, a condition in InMemoryStorage that was always true, string.Equals and a CancellationToken in tests.
  • The two Substring concatenations keep the netstandard2.0 compatible form with a CA1845 suppression, matching the existing pattern in FileSystemInitializerExtensions.

Suppressed with a reason

  • S5445: PathWrapper.GetTempFileName has to mirror the BCL.
  • S2372: FileInfoMock.Length throws like the real FileInfo.Length.
  • S3011: the FileSystemWatcherMock reflection is needed to simulate the path separator of another OS.
  • S3060: the span Is overloads of ParameterDescription check the recording subclass.
  • S2325: extension properties cannot be static.
  • MA0204: the partial compression test classes have a second part only with FEATURE_COMPRESSION_ASYNC.

Since .NET 11 the BCL offers char overloads with a StringComparison parameter, so the analyzer flags the char-only calls. Pass StringComparison.Ordinal explicitly and add the missing IndexOf(char, int, StringComparison) polyfill for older frameworks. The EndsWith(char) polyfill in the compression package is no longer used and is removed.

Also address the remaining mechanical findings: adjacent NextInt64 overloads, HasFlag instead of a bitwise check, a merged nested if, a nested ternary, a condition that is always true, string.Equals and a CancellationToken in tests, and CA1845 suppressions for netstandard2.0 compatible Substring concatenations, matching the existing pattern.
These findings are intentional or false positives, so suppress them where they occur with a short reason instead of keeping them only as accepted issues in SonarCloud: the wrapper mirrors `Path.GetTempFileName`, `FileInfoMock.Length` throws like the real property, the `FileSystemWatcherMock` reflection simulates the path separator of another OS, the span `Is` overloads of `ParameterDescription` check the recording subclass, extension properties cannot be static, and the `partial` test classes have a second part only on frameworks with async compression APIs.
@vbreuss vbreuss self-assigned this Nov 2, 2026
@vbreuss
vbreuss enabled auto-merge (squash) November 2, 2026 07:23
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@mergify

mergify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Test Results

     80 files       80 suites   1h 38m 11s ⏱️
 87 870 tests  83 180 ✅  4 690 💤 0 ❌
202 670 runs  182 964 ✅ 19 706 💤 0 ❌

Results for commit 50b1aa2.

@vbreuss
vbreuss merged commit 2154a07 into main Nov 2, 2026
14 checks passed
@vbreuss
vbreuss deleted the fix/sonar-issues branch November 2, 2026 08:08
@github-actions

Copy link
Copy Markdown

This is addressed in release v8.0.0.

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