Sonar

Honor Checkstyle Suppressions XML Document

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.3
  • Component/s: Checkstyle
  • Labels:
    None
  • Number of attachments :
    0

Description

This enhancement is a continuation of the work done in SONAR-208.

One of Checkstyle's filters is the SuppressionFilter. This filter offers advantages over the SuppressionCommentFilter by easily enabling suppression of multiple violations without adding comments for each one. For example, it allows you to suppress magic number checks in all test code rather than cluttering the code with all the comment suppressions.

It would be very helpful for Sonar to recognize the same filter.

Issue Links

Activity

Hide
Harald Göttlicher added a comment -

The parameters of the SuppressionCommentFilter could be supported.

E.g. the parameter "OffCommentFormat" could be used to check for "CHECKSTYLE\:OFF.{10,}", that means I use the default tag, but it is mandatory to write a comment behind it, i. e. why you suppressed the check.

Additionally the SuppressWithNearbyCommentFilter with its parameters could be supported.

Filters and parameters see:
http://checkstyle.sourceforge.net/config.html#Filters

Show
Harald Göttlicher added a comment - The parameters of the SuppressionCommentFilter could be supported. E.g. the parameter "OffCommentFormat" could be used to check for "CHECKSTYLE\:OFF.{10,}", that means I use the default tag, but it is mandatory to write a comment behind it, i. e. why you suppressed the check. Additionally the SuppressWithNearbyCommentFilter with its parameters could be supported. Filters and parameters see: http://checkstyle.sourceforge.net/config.html#Filters
Hide
Stefan Prange added a comment -

It would be really great if the suppressions.xml would be recognized by Sonar. I just had to drop Sonar and go back to using simple Maven site generation today because of this issue. My problem is, that I want to exclude generated code files from the Checkstyle check. Since one of the generators (the Netbeans GUI Editor) can't be customized, there is no way to place the On/Off-Comments into that code.
Furthermore, I'd be quite reluctant to activate the SuppressionCommentFilter, because that would enable all developers in my team to exclude their code from being checked.

Show
Stefan Prange added a comment - It would be really great if the suppressions.xml would be recognized by Sonar. I just had to drop Sonar and go back to using simple Maven site generation today because of this issue. My problem is, that I want to exclude generated code files from the Checkstyle check. Since one of the generators (the Netbeans GUI Editor) can't be customized, there is no way to place the On/Off-Comments into that code. Furthermore, I'd be quite reluctant to activate the SuppressionCommentFilter, because that would enable all developers in my team to exclude their code from being checked.
Hide
Freddy Mallet added a comment -

With the new Sonar Checkstyle plugin 'filters' parameter (see SONAR-1328), this is now possible to activate the SuppressFilter. Configuration example :

<mode name="Checker">
  <module name="SuppressionFilter">
    <property name="file" value="docs/suppressions.xml"/>
  </module>
 <module name="SuppressionCommentFilter"/>
</module>

Of course, the project team must maintain the suppressions XML document on each project.

Show
Freddy Mallet added a comment - With the new Sonar Checkstyle plugin 'filters' parameter (see SONAR-1328), this is now possible to activate the SuppressFilter. Configuration example :
<mode name="Checker">
  <module name="SuppressionFilter">
    <property name="file" value="docs/suppressions.xml"/>
  </module>
 <module name="SuppressionCommentFilter"/>
</module>
Of course, the project team must maintain the suppressions XML document on each project.

People

Vote (10)
Watch (9)

Dates

  • Created:
    Updated:
    Resolved: