SonarQube with C # plugin with MSBuild Runner accept no exceptions

I currently have a SonarQube 5.1.2 instance with a C # plugin and an MSBuild runner to analyze the LOC 1,200,000 project. I intend to reduce the parsed classes, I created a sonar.properties file with a line

sonar.exclusions=**/Databases/**/*.* 

but after reading the log from the analysis, the files in the "Databases" folder were analyzed. following Eric Starr’s instructions, I set up this simple exception rule in a runner’s challenge:

 "C:\sonarqube-5.1.2\bin\MSBuild.SonarQube.Runner.exe" begin /k:MyProject /n:MyProject /v:2 /d:sonar.exclusions="file:C:\codesource\Databases/**/*.*" /d:sonar.scm.provider=tfvc /d:sonar.tfvc.username=************* /d:sonar.tfvc.password.secured={aes}*************************** "/d:sonar.cs.vscoveragexml.reportsPaths=C:\codesource\CodeCoverage\Results.coveragexml" 

I found that the runner creates the sonar-project.properties file and contains many files located in the database folder:

 BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.projectName=myDatabase BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.projectBaseDir=BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.projectName=myDatabase BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.projectBaseDir=C:\\codesource\\Databases\\myDatabase BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.sources=\ C:\\codesource\\Databases\\myDatabase\\Scripts\\PreDeployment\\PATCH_20150527_01.sql,\ C:\\codesource\\Databases\\myDatabase\\Scripts\\PreDeployment\\ROCOMMON.DBVERSION.sql,\ ,\..... 

as I understand it, there should be no files in the database folder. I'm wrong?

+5
source share
1 answer

You are using the SonarQube Scanner for MSBuild , which is very different from the usual SonarQube scanner used for all other languages.

The sonar.exclude line that you are trying to use will only work if you use a regular SonarQube scanner because it takes up the Sonar-project.properties file. SonarQube Scanner for MSBuild contains only the SonarQube.Analysis.Xml file, which contains project-related parameters that you can configure.

You can use a couple of rewrite strategies for the SonarQube.Analysis.Xml file:

  • A project-specific property defined in the MSBuild * file. * proj (corresponding to the SonarQube module), can override:
  • A property defined on the command line (/ d: propertyName = value) can override:
  • Property defined in SonarQube.Analysis.xml configuration file
  • A property defined in the SonarQube user interface at the project level that can override everything
  • A property defined in the SonarQube user interface at the global level that cannot override anything

To exclude specific folders or extensions from your solution:

You need to add an exception to the .csproj file of each individual project. Here is the syntax you should use in the main root of the node called <Project...> , and for one of the goals, preferably <Target Name="BeforeBuild"> . I hope that the syntax below is clear enough, but if this is not the case, please leave a comment in this answer and I will update it immediately.

 <Target Name="BeforeBuild"> <ItemGroup> <SonarQubeSetting Include="sonar.exclusions"> <Value>**/Databases/**/*</Value> </SonarQubeSetting> </ItemGroup> </Target> 

Hope this helps!

Source

+8
source

Source: https://habr.com/ru/post/1243955/


All Articles