New StyleCop errors during MS build when server upgraded

Hi there, I’m upgrading our SonarQube server from 6.7.5 to 7.9.1. I have two instances of the server set up; one with the old version, and one with the new. We build using Jenkins and use the SonarQube Scanner plugin (version 2.9).

When I point one of our jobs to the old server the build works. But when I point the job to the new server, I get a bunch of errors that start with SA or SX, By what I understand these are StyleCop errors. Here is an example of one of the errors:

error SA1305: variable 'xChar' should not use Hungarian notation

I dug into the logs and I noticed this in the builds that point to the old server:

SetRoslynCodeAnalysisProperties:
   External issues are not supported on this version of SonarQube. SQv7.4+ is required.

Builds that point to the old server also has this as one of the parameters:

/ruleset:"C:\jenkins\workspace\my_job\.sonarqube\conf\SonarQubeRoslyn- cs.ruleset"

whereas builds that point to the new serve as this as one of the parameters:

/ruleset:"C:\jenkins\workspace\my_job\.sonarqube\conf\2\merged.ruleset"

Also, these parameters are new when pointing to the new server:

/analyzer:C:\Users\winbuild\AppData\Local\Temp\.sonarqube\resources\2\Google.Protobuf.dll
/analyzer:C:\Users\winbuild\AppData\Local\Temp\.sonarqube\resources\2\SonarAnalyzer.dll
/analyzer:C:\Users\winbuild\AppData\Local\Temp\.sonarqube\resources\2\SonarAnalyzer.VisualBasic.dll
/analyzer:C:\jenkins\workspace\my_job\nuget_packages\stylecop.analyzers\1.1.118\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll
/analyzer:C:\jenkins\workspace\my_job\nuget_packages\stylecop.analyzers\1.1.118\analyzers\dotnet\cs\StyleCop.Analyzers.dll

So by what I can gather, the old server didn’t allow external issues, but now the new server does. I’ve tried to figure out where to find these rules or how to configure external issues, or StyleCop, etc., but I’m just not quite getting it. I’m not entirely sure where to look. I looked in Rules, Quality Profiles, and Quality Gates, but I don’t see exactly how to I can control which analyzers are chosen when running the build. I’m sure this is easy and I’m just missing it… Any ideas?

Thanks!

Rob

hi @Rob_Duff

From Importing External Issues:

Notes on external .NET issues

Issues from third-party Roslyn analyzers (including Roslyn analyzers provided by Microsoft) are included in the MSBuild output and imported by default into SonarQube so no properties exist to enable that behavior. Instead, properties are available to adjust the import and to stop importing those issues.

To stop importing StyleCop results, you need to set sonar.cs.roslyn.ignoreIssues to true

Does this answer your question?

Andrei, I think this does! I’m going to give it a try. Thanks very much!

Rob

ok, let me know how it goes!

Hi Andrei,

That sort of worked, but it appears that I don’t have a sonar-report.json file generated any longer. I had to remove the sonar.analysis.mode=preview line in order for the build to pass… Is that related at all?

this is unrelated. sonar.analysis.mode has been deprecated since SQ 6.6 and it has been dropped in the latest LTS.