fix: resolve ~400 SonarQube maintainability and Roslyn analyzer issues#560
Merged
fix: resolve ~400 SonarQube maintainability and Roslyn analyzer issues#560
Conversation
- MA0076 (136): Add CultureInfo.InvariantCulture to interpolated strings - VSTHRD111 (54): False positives in test code - conflict with xUnit1030 - MA0003 (28): Use named parameters for clarity - MA0020 (13): Replace All() with TrueForAll() for List<T> - CA1860 (16): Prefer Count > 0 over Any() - IDE0028 (35): Simplify collection initialization - CA1859 (15): Use concrete return types instead of interfaces - CA1861 (14): Extract inline arrays to static readonly fields - MA0089 (18): Use char overloads instead of single-char strings - CA1869 (11): Cache JsonSerializerOptions as static readonly - MA0159 (12): Use Order instead of OrderBy - xUnit1030 (23): Remove ConfigureAwait(false) from test methods - IDE0055 (8): Fix formatting - CA1816 (5): Add GC.SuppressFinalize to Dispose methods - CA1822 (3): Make non-instance methods static - MA0042 (5): Use await using for IAsyncDisposable - MA0053 (5): Seal internal classes - MA0006 (6): Use string.Equals for string comparisons - MA0075 (1): Fix implicit culture-sensitive ToString - MA0078 (1): Use Cast<> instead of Select - MA0071 (1): Remove redundant else - MA0160 (2): Use ContainsKey instead of TryGetValue - MA0031 (2): Replace Count() > 1 with Skip(1).Any() - S6677 (1): Make log template placeholders unique - S108 (4): Fill empty catch blocks - S1118 (1): Make ProviderRefreshConfigSelector static - S1133 (1): Add removal date to obsolete attribute - S4487 (1): Remove unread private field - S2139 (1): Pass exception to logger - SYSLIB1054 (1): Use LibraryImport instead of DllImport - SA1210 (1): Reorder using directives - SA1502 (1): Expand single-line element - CA1835 (2): Use Memory<byte> overloads for ReadAsync/WriteAsync - CA1845 (1): Use AsSpan + string.Concat
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.
Summary
Fixes ~400 SonarQube maintainability issues across 68 files, including:
High-impact fixes:
CultureInfo.InvariantCultureto interpolated strings to avoid culture-sensitiveToString()calls.Any()with.Count > 0for collections with Count propertystatic readonlyfieldsJsonSerializerOptionsasstatic readonlyfieldsOrder()instead ofOrderBy()charoverloads instead of single-char strings.All()with.TrueForAll()forList<T>Reliability fixes:
ProviderRefreshConfigSelectora static class_configSelectorCode quality:
ConfigureAwait(false)from test methodsGC.SuppressFinalizeto Dispose methodsawait usingforIAsyncDisposableLibraryImportinstead ofDllImportMemory<byte>overloadsAsSpan+string.ConcatNote: 54 VSTHRD111 (ConfigureAwait) issues in test code are intentionally skipped - they conflict with xUnit1030.
Test plan
dotnet build- 0 errors, 0 warnings