Search code examples
c#visual-studio-2015sonarqubesonarlintsonarlint-vs

Remove Auto-generated Code from SonarLint Analysis


Background

I am running Visual Studio 2015 Enterprise (RTM) and have enabled the SonarLint extension for code analysis of my multi-project ASP.NET 4.5 MVC solution.

Problem

SonarLint analysis seems to be ignoring the project setting for Code Analysis "Suppress results from generated code (managed only)"

That is, I'm getting a lot of Sonar errors reported back for a couple of *.designer.cs files generated from some .aspx pages. (Most of the project is MVC, for what it's worth.) I don't care about these errors, and don't think I have a decent path for fixing them...

More Details

I have SonarQube integrated with our TFS 2013 environment, and it is correctly ignoring these issues on the TFS server analysis. This problem is just showing up in Visual Studio, using the Roslyn analysis.

Any ideas how I can set up the equivalent of an .ignore file or otherwise fix this?


Solution

  • There is no built-in way of ignoring files in Roslyn at the moment, so you can't do it. Each analyzer needs to decide if the analyzed file needs to be checked or not. Specifically for SonarLint, I've created an issue on GitHub: https://github.com/SonarSource/sonarlint-vs/issues/85. You can track its progress.