dennisdoomen / CSharpGuidelines

A set of coding guidelines for C# 9.0, design principles and layout rules for improving the overall quality of your code development.
https://www.csharpcodingguidelines.com
Other
746 stars 271 forks source link

Consider creating a ruleset for SonarQube #178

Open SierraNL opened 6 years ago

SierraNL commented 6 years ago

I'm at a company which uses these guidelines, but also uses SonarQube, a tool which is used more and more in CI / CD pipelines.

It might be a good idea to create a matching ruleset for SonarQube. I think most rules are already implemented: https://rules.sonarsource.com/csharp But new ones can be added through: https://github.com/SonarSource/sonarqube-roslyn-sdk

bkoelman commented 6 years ago

@SierraNL Nice suggestion!

Did you know that CSharpGuidelinesAnalyzer provides 45 roslyn-based analyzers, which were written specifically for the rules in this repository? See here for an overview.

It would be nice to integrate those with SonarQube. However, it looks like SonarQube requires external analyzers to work with v1.x of the Roslyn API, which is very old. CSharpGuidelinesAnalyzer has always depended on newer APIs. So although I have not actually tried, based on documentation I think it is not going to work.

If you want to try out CSharpGuidelinesAnalyzer, I strongly recommend to use a recent prerelease build. I'm in the final testing stage before releasing a new stable version, which will be a major overhaul compared to the current release.

bkoelman commented 5 years ago

Looks like this should be possible now. Is there still interest for such an integration?

SierraNL commented 5 years ago

Yes, I would really like to see that integration.

bkoelman commented 5 years ago

@SierraNL Can you try the steps at https://github.com/SonarSource/sonarqube-roslyn-sdk#getting-started?

RoslynSonarQubePluginGenerator.exe /a:CSharpGuidelinesAnalyzer

It successfully generates a .jar file for me. You should be able to install that into SonarQube.