How do I add a quality gate for public API functions undocumented for C# code

Must-share information (formatted with Markdown):

  • SonarQ server: 8.1.0.31237

  • SonarC#**: Code Analyzer for C# * 8.2 (build 14119) installed

  • My intention is to add some kind of quality gate, or rule to check that all public functions or properties are properly documented.
    At least it should check that there are comment lines over the public function.
    Ideally it should check deeply like stylecop does, that the comments have a correct format.

I have search the web and found some custom validations that were supported in very old sonarq versions, 5.0 or previous. But I found no way to reach a similar behaviour in our current deployment.

The closer thing I can think of is a code smell rule inside the Java analyzer.

I fear that currently there is no way to check for documentation quality in the code right now for C#. Am I right?

hi @Guillermo_Alias

That’s correct.

You can import issues from external analyzers to SonarQube. From the docs

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.

Does this answer your question? (you can use the StyleCop analyzer in your CI build and the issues will be imported in SonarQube)

Hi.

Last time I check stylecop plugin was deprecated.

Also stylecop was extremely picky, way over my current purpose which is just public functions comments.

So my desire would be to have some rules over code styling under Sonar.

Thank you for answering.

hi

did you try with the Roslyn-based StyleCopAnalyzers ? You should be able to select from it only the rules you want to run using a ruleset file