sonar-dotnet icon indicating copy to clipboard operation
sonar-dotnet copied to clipboard

Code analyzer for C# and VB.NET projects

Results 507 sonar-dotnet issues
Sort by recently updated
recently updated
newest added

### 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...

Rule Idea

### 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...

False Positive

See internal forum https://discuss.sonarsource.com/t/new-rule-c-vb-net-propagate-cancellation-tokens/555

Rule Idea

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] ==...

Rule Idea

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...

False Positive

### 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...

False Positive

### 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 -...

False Positive

### 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 ```...

False Positive

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...

Rule Idea

Extend [S119](https://sonarsource.github.io/rspec/#/rspec/S119/vbnet) to CSharp (it's already implemented in VB)

Rule Idea