Sonar

Enable CheckStyle SuppressionCommentFilter module

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1, 1.2, 1.2.1, 1.3
  • Fix Version/s: 1.9
  • Component/s: Checkstyle, Rules
  • Labels:
    None
  • Number of attachments :
    0

Description

The CheckStyle SuppressionCommentFilter module should be handled by Sonar, since it allows the developers to suppress some CheckStyle rule violations in the code using a commentary.
For your information, it is always possible to suppress some PMD rule violations in the code using @SuppressWarnings annotation, but for CheckStyle, this functionality does not use annotation but tags in single comment lines, and is not available by default.

With the SuppressionCommentFilter module activated in CheckStyle, the XML file should be generated with:

<module name="Checker">
...
<module name="SuppressionCommentFilter"/>
<module name="TreeWalker">
<module name="FileContentsHolder" />
...
</module>
</module>

It'll great if we can also setup the properties of this filter.

Issue Links

Activity

Hide
Simon Brandhof added a comment -

What a shame that checkstyle does not manage the standard way used by PMD. This is a recurrent need wanted for sonar (see SONAR-208). We keep it actively in mind for next releases.

Show
Simon Brandhof added a comment - What a shame that checkstyle does not manage the standard way used by PMD. This is a recurrent need wanted for sonar (see SONAR-208). We keep it actively in mind for next releases.
Hide
Freddy Mallet added a comment -

Simon, can't we imagine to define a boolean option on Sonar Chectyle Plugin to handle this feature ?

Show
Freddy Mallet added a comment - Simon, can't we imagine to define a boolean option on Sonar Chectyle Plugin to handle this feature ?
Hide
Dominique Jean-Prost added a comment -

To my mind, if it's not complicated to implement, it should be added as quick as possible.
In my case, it prevents me to use the checktyle file generated by sonar in eclipse or maven plugin. The consequence is that when I change something in my checkstyle rules, I have to do it twice : in sonar, and in my external checkstyle file (used by eclipse and maven plugin).

Show
Dominique Jean-Prost added a comment - To my mind, if it's not complicated to implement, it should be added as quick as possible. In my case, it prevents me to use the checktyle file generated by sonar in eclipse or maven plugin. The consequence is that when I change something in my checkstyle rules, I have to do it twice : in sonar, and in my external checkstyle file (used by eclipse and maven plugin).
Hide
Freddy Mallet added a comment -

In Sonar 1.9, we'll handle only the default behavior by adding the following line in the checkstyle configuration file

<module name="SuppressionCommentFilter"/>

So rules violations between a comment containing CHECKSTYLE:OFF and a comment containing CHECKSTYLE:ON will be ignore :

//CHECKSTYLE:OFF
      int toto = tata;
      toto.myCheckstyleError();    
//CHECKSTYLE:ON
Show
Freddy Mallet added a comment - In Sonar 1.9, we'll handle only the default behavior by adding the following line in the checkstyle configuration file
<module name="SuppressionCommentFilter"/>
So rules violations between a comment containing CHECKSTYLE:OFF and a comment containing CHECKSTYLE:ON will be ignore :
//CHECKSTYLE:OFF
      int toto = tata;
      toto.myCheckstyleError();    
//CHECKSTYLE:ON
Hide
Dominique Jean-Prost added a comment -

that's ok for me

Show
Dominique Jean-Prost added a comment - that's ok for me

People

Vote (6)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
4h
Original Estimate - 4 hours
Remaining:
4h
Remaining Estimate - 4 hours
Logged:
Not Specified
Time Spent - Not Specified