How to make Sonarqube exclude a .NET (C#) project from coverage measures

前端 未结 6 1178
Happy的楠姐
Happy的楠姐 2021-02-05 14:07

Sonarqube allows for individual files to be excluded from code coverage by adding patterns in the sonar.coverage.exclusions key. This can be done on a project level by

6条回答
  •  你的背包
    2021-02-05 15:06

    Some notion :

    A .NET solution is Sonarqube's project. A .NET solutions's project is Sonarqube's project's module.

    I find two solutions to exlcure Sonarqube's module (.NET project) from code coverage.

    1) Configure exclusion from Web UI Sonarqube

    From : SonarQube MSBuild Scanner doesn't exclude files from analysis

    • Open Sonarqube's project -> Code (in top menu)
    • Open Sonarqube's module (left icon 'Open Component's Page) -> Administration (in top menu) -> General Settings
    • Add ** in Codecoverage exclusion :

    (Screenshot in French, but you get the idea)

    2) Add the property "sonar.coverage.exclusions" in csproj

    In your <.NET project>.csproj, add :

    
      ...
      
        
          
            **
          
        
      
      ...
    
    

    This two solutions work for me, but I would prefer a global setting for Sonarqube's project (.NET Solution).

提交回复
热议问题