sonar-dotnet
sonar-dotnet copied to clipboard
Code analyzer for C# and VB.NET projects
### Description Consider adding a rule to replace usages of `StringComparison.InvariantCulture` and `StringComparison.InvariantCultureIgnoreCase` with `StringComparison.Ordinal` and `StringComparison.OrdinalIgnoreCase` respectively. This aligns with the advice provided at that https://docs.microsoft.com/dotnet/standard/base-types/best-practices-strings: > Do not...
### Description `Remove the 'FlagsAttribute' from this enum` is displayed, although the enum only uses power of two values. ### Repro steps Define the following enum: ```csharp [Flags] public enum...
See internal forum https://discuss.sonarsource.com/t/new-rule-c-vb-net-propagate-cancellation-tokens/555
When using the hat `^` operator to index an array, the values that make sense are `1..Length`. This is because it is practically the same as : ```csharp arr[^REVERSE_INDEX] ==...
Currently S3063 does not support extension methods resulting in the following FP: ```cs StringBuilder sb = new(); // Noncompliant FP sb.ToStringAndFree(); public static class StringBuilderExtensions { public static string ToStringAndFree(this...
### Description Currently S3063 does not support null-conditional operators resulting in the following FP: ```cs var sb = new StringBuilder(); // FP sb?.Append("").ToString().ToLower(); ``` The implementation should be easier once...
### Description [S4049](https://rules.sonarsource.com/csharp/RSPEC-4049) is not part of SonarWay and is debatable. However, it should never tell people to: - move big methods (10, 20 , 100 LOCs) into properties -...
### Description As reported on [internal discuss](https://discuss.sonarsource.com/t/c-s3626-fp-what-the-deal-with-the-operator/4291) , S3626 causes FP when there's a binary branch inside Finally block. This could be fixed without reshaping CFG. ### Repro steps ```...
The rule should raise an issue when invoking one or more methods decorated with the [ConditionalAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.conditionalattribute?view=net-7.0) [System.Diagnostics.Conditional("DEBUG")] inside a `#if DEBUG` conditional preprocessor directive. The calls to the method will...
NET-1719 New Rule Idea: Generic type parameter names should comply with a naming convention (S119)
Extend [S119](https://sonarsource.github.io/rspec/#/rspec/S119/vbnet) to CSharp (it's already implemented in VB)