Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-epure-sonarsource committed Nov 16, 2020
1 parent a5fc6d2 commit 7228633
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,21 @@ public class ExpressionComplexityTest
{
[TestMethod]
[TestCategory("Rule")]
public void ExpressionComplexity_CSharp()
{
var diagnostic = new SonarAnalyzer.Rules.CSharp.ExpressionComplexity { Maximum = 3};
public void ExpressionComplexity_CSharp() =>
Verifier.VerifyAnalyzer(@"TestCases\ExpressionComplexity.cs",
diagnostic,
new SonarAnalyzer.Rules.CSharp.ExpressionComplexity { Maximum = 3},
options: ParseOptionsHelper.FromCSharp8);
}

[TestMethod]
[TestCategory("Rule")]
public void ExpressionComplexity_CSharp9()
{
var diagnostic = new SonarAnalyzer.Rules.CSharp.ExpressionComplexity { Maximum = 3};
Verifier.VerifyAnalyzerFromCSharp9Console(@"TestCases\ExpressionComplexity.CSharp9.cs", diagnostic);
}
public void ExpressionComplexity_CSharp9() =>
Verifier.VerifyAnalyzerFromCSharp9Console(@"TestCases\ExpressionComplexity.CSharp9.cs",
new SonarAnalyzer.Rules.CSharp.ExpressionComplexity { Maximum = 3});

[TestMethod]
[TestCategory("Rule")]
public void ExpressionComplexity_VisualBasic()
{
var diagnostic = new SonarAnalyzer.Rules.VisualBasic.ExpressionComplexity { Maximum = 3 };
Verifier.VerifyAnalyzer(@"TestCases\ExpressionComplexity.vb", diagnostic);
}
public void ExpressionComplexity_VisualBasic() =>
Verifier.VerifyAnalyzer(@"TestCases\ExpressionComplexity.vb",
new SonarAnalyzer.Rules.VisualBasic.ExpressionComplexity { Maximum = 3 });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,10 @@ public void Dispose()
throw new Exception(); // Noncompliant
}
}

class ArrowMethods : IDisposable
{
static ArrowMethods() => throw new Exception(); // FN, needs support for throw expressions
public void Dispose() => throw new Exception(); // FN
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
object x = null;
var d1 = true && false && true && false && true && true; // Noncompliant

object x = null;

if (x is true or true or true or true or true) { } // FN

if (x is true and true and true and true and true) { } // FN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
var x = 1;
var isTopLevelFile = true;

public record GlobalRecord { }

public static class GlobalExtensions
{
public static void Bar(this GlobalRecord r) { } // Noncompliant
}

namespace MyLibrary
{
public record Foo { }
Expand Down

0 comments on commit 7228633

Please sign in to comment.