Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NOSONAR tag to ignore an invalid issue still shows as an issue

I have the below method which is showing a sonar issue saying the method is not used anywhere.

@Provides
@ObjectMapperAnnotation
 public ObjectMapper provideObjectMapper() { //NOSONAR
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JsonOrgModule());
    return mapper;

}

But this is a method that is called by the guice library and I do not have to call it explicitly. So in order to compress this issue I used the NOSONAR tag as shown above. But it still is showing a major issue as shown below.

Is //NOSONAR used to exclude false-positive or to hide real quality flaw ? 

How can I avoid this issue being shown for using the NOSONAR tag? Any help would be much appreciated.

like image 427
AnOldSoul Avatar asked Aug 18 '16 02:08

AnOldSoul


1 Answers

Looks like the squid:NoSonar rule is activated in the Quality Profile used by this project, precisely to avoid developers silently marking stuff as NOSONAR i.e. sweep problems under the carpet.

Moving forward:

  • let the original issue be raised in SonarQube (the one saying the method is not used anywhere)
  • discuss it with your team to be sure it's a false-positive
  • close it as False Positive in SonarQube (you can do that right form the UI when managing your issues)
  • get beer
like image 127
Nicolas B. Avatar answered Sep 17 '22 19:09

Nicolas B.