Menu

Showing posts with label NOSONAR. Show all posts
Showing posts with label NOSONAR. Show all posts

How to exclude or skip some line of code from Sonar violations

Exclude and skip any line of code from Sonar, so sonar will not run the violation check on that line of code. This could be done by adding a comment "//NOSONAR" at the end of line of code or block of code.

For example, in this code Sonar is raising Critical vulnerability, but this needs to be present in the code and something which cannot be changed. So, in this situation, to run the sonar successfully, this line of code should get excluded from Sonar violation check, and to do so, there will be a comment //NOSONAR needs to get added at the end of this line of code. 

e.g.

AlgorithmParameterSpec paramSpec = new IvParameterSpec(IVAes); //NOSONAR


Reference

https://www.baeldung.com/sonar-exclude-violations