Skip to content

Commit

Permalink
Remove the duplication special handling
Browse files Browse the repository at this point in the history
  • Loading branch information
costin-zaharia-sonarsource committed Mar 22, 2024
1 parent e2f3ea0 commit 97d80f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ private void ReportIssues(SonarSymbolReportingContext context, ISymbol symbol, C
if (declaration.GetIdentifier() is { } identifier)
{
context.ReportIssue(CSharpGeneratedCodeRecognizer.Instance, Diagnostic.Create(Rule, identifier.GetLocation(), secondaryLocations));

// When a symbol was declared in multiple locations, we want to avoid reporting the same secondary locations multiple times.
// The list is cleared only if the declaration is not in generated code. Otherwise, the secondary locations are not reported at all.
if (!Language.GeneratedCodeRecognizer.IsGenerated(declaration.SyntaxTree))
{
secondaryLocations.Clear();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ public void SpecifyRouteAttribute_PartialClasses_CS() =>
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
public partial class HomeController : Controller // Noncompliant
public partial class HomeController : Controller // Noncompliant [first]
{
[HttpGet("Test")]
public IActionResult Index() => View(); // Secondary
public IActionResult Index() => View(); // Secondary [first, second]
}
""")
.AddSnippet("""
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
public partial class HomeController : Controller // Noncompliant
public partial class HomeController : Controller // Noncompliant [second]
{
}
""")
Expand Down

0 comments on commit 97d80f8

Please sign in to comment.