NOSONAR not working for ignoring test coverage issue

Hi we are using sonarqube + C# for projects. When I pushed the new PR, the sonarqube asks me to add unit tests to cover the new lines, however, those lines are for swagger examples which we do not necessarily need a test for them. Thus, I added the //NOSONAR to ignore sonarqube for those lines but the sonarqube check still fails, as the picture below shows.

Also, is there any way we can ignore multiple lines/files instead of adding //NOSONAR at every single line of code?

1 Like

Hi @M1ngz_Kve,

Welcome to SonarSource community! :wave:

//NOSONAR works to disable false-positive issues, not code coverage. To disable the code coverage for these particular files, you can set the sonar.coverage.exclusions parameter at project level (in SonarQube 7.9, go to your project dashboard > Administration > General Settings > Analysis Scope) or global level (in SonarQube 7.9, go to Administration > Configuration > General Settings > Analysis Scope) and add your exclusion pattern there.

Joe

Hi Joe,

Thanks for the help. But will this affect my other PRs? I still want the coverage check but just want to exclude some calsses.

Hi, Just get the access to the administration and found out I Can specify the exclusions for the target files, that should solve my problem. Thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.