Skip to content

Commit

Permalink
more UTS
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource committed Feb 16, 2023
1 parent eed9667 commit 73f5639
Show file tree
Hide file tree
Showing 2 changed files with 7 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 @@ -18,6 +18,11 @@ public class StaticFieldVisible
internal static double Pi6 = 3.14; // Noncompliant
protected internal static double Pi7 = 3.14; // Noncompliant

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 73f5639

Please sign in to comment.