Skip to content

Commit

Permalink
increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource committed Feb 16, 2023
1 parent 27476a8 commit d39f5ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Expand Up @@ -49,7 +49,8 @@ public sealed class StaticFieldVisible : SonarDiagnosticAnalyzer
: Enumerable.Empty<Diagnostic>();

private static bool FieldIsRelevant(FieldDeclarationSyntax node) =>
!node.Modifiers.Any(SyntaxKind.PrivateKeyword)
node.Modifiers.Any()
&& !node.Modifiers.Any(SyntaxKind.PrivateKeyword)
&& node.Modifiers.Any(SyntaxKind.StaticKeyword)
&& !(node.Modifiers.Any(SyntaxKind.ConstKeyword) || node.Modifiers.Any(SyntaxKind.ReadOnlyKeyword));

Expand Down
Expand Up @@ -20,6 +20,8 @@ public class StaticFieldVisible

private static double Pi8 = 3.14;
private double Pi9 = 3.14;
static double Pi10 = 3.14; // Noncompliant "internal" is the default if no access modifier is specified
// https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers

[ThreadStatic]
public static int value; // Compliant, thread static field values are not shared between threads
Expand Down

0 comments on commit d39f5ee

Please sign in to comment.