Configuring sonar.issue.ignore.block with regular expression

  • SonarScanner
  • SonarQube™ Enterprise Edition Version 10.3 (build 82913)
  • Swift Xcode Project
  • Jenkins Pipeline Job
  • per repository
  • Server defined sonar.issue.ignore.allfile //\s*@nosonarscan

The coverage report is given to SonarQube but adding
// @nosonarscan to one of the source files is not taking into account. (should be ignored for coverage reporting)

Is this supposed to work how we did it?


not sure if i understand correctly.

There’s a property named sonar.issue.ignore.allfile for ignoring all issues on a file.
And a property named sonar.coverage.exclusions to exlude the file(s) from coverage.

The first one works via regex, i.e. this works

one regex per line.

Whereas the second takes glob patterns, i.e. **/foo*.java
One entry per line in Sonarqube server, a comma separated list in or CLI parameter.





The RegEx we are using “\/\/\s*@nosonarscan” is not ignored when I use it within a file.

// Copyright (c) AOK Systems GmbH. All rights reserved.

// @nosonarscan
struct FeatureX {

i think the regex could be simplified to just @nosonarscan

But your question was

Did you try the property sonar.coverage.exclusions ?

Just tried it out (@nosonarscan). Doesn’t work.

Using sonar.coverage.exclusions would remove the file completely from SonarQube “Code” Tab.
We are using sonar.sources and sonar.inclusions but for specific files we would like to be able to mark them in code as @nosonarscan

Think i got you wrong.

Problem is the sonar.issue.ignore.allfile server setting doesn’t work.
And “should be ignored for coverage” means it should have no impact on the coverage reporting.

Right ?

Here is how it looks like