Can't ignore issues in blocks

623 views
Skip to first unread message

Kumar Gaurav

unread,
Apr 23, 2018, 9:38:56 AM4/23/18
to SonarQube
Dear All, I am trying to ignore issues in blocks as described in documentation: https://docs.sonarqube.org/display/SONAR/Narrowing+the+Focus#NarrowingtheFocus-IgnoreIssues

I have some duplicated code in ClassA.java and ClassB.java and sonarqube complains about them as code smells. I want to ignore it in sonar analysis. So I am putting the code block like following in both files:

//START_NO__SONAR
//mycode to ignore
//END_NO__SONAR

In Sonarqube UI settings for sonar.issue.ignore.block: beginBlockRegexp is set as START_NO__SONAR and endBlockRegexp is set as END_NO__SONAR. However Sonarqube still complains about that and reports them as code smells.
I am wondering what I am doing wrong.. My sonarqube version is 7.1.

Please let me know if I am missing something.

Thanks a lot,
Kumar

G. Ann Campbell

unread,
Apr 23, 2018, 9:56:58 AM4/23/18
to SonarQube
Hi Kumar,

You're not doing anything wrong. This combination just doesn't work. :-/

The rule about duplicated blocks (among others) is a "common" rule and that type of exclusion doesn't work on common rules. This closed ticket holds some relevant details. This open ticket is about the future of that exclusion type.


Ann

Kumar Gaurav

unread,
Apr 23, 2018, 10:55:55 AM4/23/18
to SonarQube
Thanks a lot Ann. The jira link helped and I could use "Ignore Issues on Multiple Criteria" to achieve that. Following worked:
Rule Key Pattern: common-java:DuplicatedBlocks 
File Path Pattern: **/*Mojo.java

Thanks & Regards,
Kumar
Reply all
Reply to author
Forward
0 new messages