Search code examples
springspring-bootgradlesonarqubesonar-runner

How to disable sonarqube security hotspot using gradle property?


I want to disable or ignore my security check from Sonar Qube for a particular code. Below the screenshot, I have used directly my entity class in the request body. And I want to keep this change.

Just want to know how do I ignore this using the Sonar Qube Gradle property

   sonarqube {
    properties {
        property("sonar.exclusions", "abc.java")
        property("sonar.jacoco.reportPath", "./test_results.exec")
        property("sonar.projectKey", "test");
        property("sonar.login", "78t87324jhjahdsgjjhsa")
        property("sonar.host.url", "https://sonarqube.test.te")
    }
}

enter image description here


Solution

  • You can suppress specific warnings by using @SuppressWarnings("squid:S00XX") where S00XX is a Sonar issue ID. You can find this ID in the Sonar UI based on your error or warning.

    For suppressing multiple warnings you can try like @SuppressWarnings({"squid:S00X1", "squid:S00X2"}) i.e. provide multiple Sonar issue IDs.

    Or you can also use //NOSONAR comment that tells SonarQube to ignore all errors for a specific line.