am having a class, which is giving me sonar issues. That is just a temporary class and I would ignore it in future sprints. How can I mark that particular class to be ignored from sonar analysis, as we have guidelines to commit code only if no sonar issues found.
annotation to skip sonar analysis on a class
12.3k Views Asked by anurag1007 AtThere are 2 best solutions below

Generally speaking you do have multiple options: (i assume you are using java, but there are equivalent solutions for other languages)
ignoring the whole class
There is a property called
sonar.exclusion
which you can set to ignore that specific class. This needs to be set either yoursonar-project.properties
or based on the scanner you are using. For details take a look hereignoring just some lines with issues
In the java world you can use line comments with
//NOSONAR <reason>
to exclude lines from detection. There are equivalents in other languages too.ignoring just some issues on the class/method
In Java you can use the
@SuppressWarnings("<rule id>")
to exclude issues from classes and methods for detection. see https://stackoverflow.com/a/30383335/3708208Define multiple ignore criteria for wildcard and rules
you can also define special settings in sonarqube, to ignore special files and folders via wildcard input, and which rules should be ignored. see https://stackoverflow.com/a/53639382/3708208
for those who use SonarLint plugin for IntelliJ Idea:
File > Settings > Tools > SonarLint > File Exclusions