Skip to content

Commit

Permalink
Fix coverage
Browse files Browse the repository at this point in the history
Remove unused method
  • Loading branch information
azarasi3 committed Sep 22, 2024
1 parent 093f928 commit 5ca9aeb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#nullable disable

namespace StyleCop.Analyzers.Test.HelperTests
{
using Microsoft.CodeAnalysis;
using StyleCop.Analyzers.Helpers;
using Xunit;

public class SyntaxTreeHelpersTests
{
[Fact]
public void TestContainsUsingAliasArgumentIsNull()
{
SyntaxTree tree = null;
Assert.False(tree.ContainsUsingAlias(null));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,49 @@ public async Task TestMethodParameterNamedDoubleUnderscoreAsync()
{
var testCode = @"public class TypeName
{
public void MethodName(int __)
public void MethodName(int __, int _)
{
}
}";

DiagnosticResult expected = Diagnostic().WithArguments("__").WithLocation(3, 32);
DiagnosticResult[] expected =
{
Diagnostic().WithArguments("__").WithLocation(3, 32),
Diagnostic().WithArguments("_").WithLocation(3, 40),
};
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
[WorkItem(2974, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2974")]
public async Task TestMethodParameterNamedIncrementUnderscoreAsync()
{
var testCode = @"public class TypeName
{
public void MethodName(int _, int __, int ___)
{
}
}";
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
[WorkItem(2974, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2974")]
public async Task TestMethodParameterNamedIrregularUnderscoreAsync()
{
var testCode = @"public class TypeName
{
public void MethodName1(int __, int _) { }
public void MethodName2(int _, int ___, int __) { }
}";

DiagnosticResult[] expected =
{
Diagnostic().WithArguments("__").WithLocation(3, 33),
Diagnostic().WithArguments("_").WithLocation(3, 41),
Diagnostic().WithArguments("___").WithLocation(4, 40),
Diagnostic().WithArguments("__").WithLocation(4, 49),
};
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
}

Expand Down
18 changes: 0 additions & 18 deletions StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxTreeHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,6 @@ public static bool IsWhitespaceOnly(this SyntaxTree tree, CancellationToken canc
&& TriviaHelper.IndexOfFirstNonWhitespaceTrivia(firstToken.LeadingTrivia) == -1;
}

/// <summary>
/// Recursively descends through the tree structure, enumerating all Statement nodes encountered during the traversal.
/// </summary>
/// <param name="syntaxNode">The syntax node to recursively.</param>
/// <returns>Enumerated StatementSyntax.</returns>
public static IEnumerable<StatementSyntax> StatementDescendRecursively(this SyntaxNode syntaxNode)
{
foreach (var statement in syntaxNode.ChildNodes().OfType<StatementSyntax>())
{
yield return statement;

foreach (var innerItem in StatementDescendRecursively(statement))
{
yield return innerItem;
}
}
}

/// <summary>
/// Recursively descends through the tree structure, enumerating all Expression nodes encountered during the traversal.
/// </summary>
Expand Down

0 comments on commit 5ca9aeb

Please sign in to comment.