Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is the warning 'Source files should not have any duplicated blocks' suppressed in SonarQube?

Tags:

java

sonarqube

I am using SonarQube 5.4 and investigating the suppressing of several issues. I've found that SonarQube does not detect the suppression of the rule Source files should not have any duplicated blocks once I insert @SuppressWarnings("common-java:DuplicatedBlocks") in the beginning of the file (the file does not compile) or at the markup of the one of the duplicated code blocks.

I've found the information at http://docs.sonarqube.org/display/PLUG/Java+FAQ which states the following:

The //NOSONAR tag is useful to deactivate all rules at a given line but is not suitable to deactivate all rules (or only a given rule) for all the lines of a method or a class. This is why support for @SuppressWarnings("all") has been added to SonarQube.

I am using the version 3.13.1 of SonarQube Java Plugin.

I am aware that I can mark the issue in the SonarQube GUI as a false positive but this will not transfer through branches which is a required feature for me.

How should I use the @SuppressWarnings-tag to disable the duplicated code block?

like image 586
Tomas Melin Avatar asked May 02 '16 13:05

Tomas Melin


People also ask

How can I check duplicate code in SonarQube?

For the other measures your should: Logon to SonarQube with your browser. Open the developer tools (hit <F12> on your keyboard) Browse to the page in SonarQube and monitor the request in the Developer Tools.


1 Answers

This is a feature that is not supported : https://jira.sonarsource.com/browse/SONARJAVA-521

There is no plan to implement it for now but this might be addressed in the future.

like image 175
benzonico Avatar answered Nov 15 '22 13:11

benzonico