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

AnOldSoul picture AnOldSoul · Aug 18, 2016 · Viewed 22.8k times · Source

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.

Answer

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