0

I'm working for a client that wants SonarLint used on their projects. Their IDE of choice is Eclipse. They do not have SonarQube. What I am looking for is a way to clear out the SonarLint annotation for a particular instance of a rule violation, rather than disabling the rule altogether.

For example, the rule about removing commented out code is useful for finding code accidentally left behind after testing, but there are occasions where commented out code is left behind because the business is not yet clear on how they want a particular routine to function. It would be helpful to be able to clear that one instance of the rule violation annotation.

Is this even possible without SonarQube?

cneff
  • 388
  • 6
  • 15

1 Answers1

1

You should add on your code an annotation with the specific rule id, and add a comment to explain, e.g. :

@SuppressWarnings("squid:CommentedOutCodeLine") //code commented out because business is not yet clear
aki
  • 91
  • 4
  • That was very helpful. However, while researching what the text should be for this error, I saw the 'Track uses of "NOSONAR" comments' rule. Looking into that more lead me to this [answer](https://stackoverflow.com/a/10972243/1804221), which led me to this [FAQ](https://docs.sonarqube.org/latest/faq/), which describes the // NOSONAR solution in detail. And even though the FAQ is for SonarQube, it works for me in this instance. – cneff Apr 22 '21 at 16:00
  • I do prefer to suppress a specific rule over using a "//NOSONAR" comment. It allows sonar to warn me if latter code modification introduce another problem. If you use the too general "//NOSONAR", you could miss some interesting hints. By the way, if this answer "was very helpful", you may consider mark it as accepted answer. – aki Jun 10 '21 at 08:47