Yes, I saw this question:
How to disable a particular checkstyle rule for a particular line of code?
But I can not comment and I wanted to ask if it is possible to do what the OP asked:
How to disable one particular rule for a line of code
I also saw this: Is there a way to force Checkstyle to ignore particular warning in the source code?
I guess the answer to my question is to use SuppressWithNearbyCommentFilter
I just don't understand what my comments in java should look like.
Say I have the following code:
public class MyDataContainer {
/** the name */
public String name;
}
and I want to get rid of the "Visibility Modifier" warning and only that warning.
What do I have to enable (using the eclipse--cs.sf.net plugin)?
And how do my comments have to look?
I managed to enable Suppresion Comment Filter and surround my whole class with
//CHECKSTYLE:OFF
//CHECKSTYLE:ON
but I don't really like this solution.
Then to disable Checkstyle, you use //CHECKSTYLE:OFF and //CHECKSTYLE:ON (default values) in your code.
In latest eclipse version(9/2014) we have to visit Help -> Eclipse Market and go to installed tab. Then select uninstall. After uninstallation this will ask for a eclipse restart. And that is it.
It is a bit late, for future reference:
you can use the SuppressWithNearbyCommentFilter this way:
<module name="SuppressWithNearbyCommentFilter">
<property name="commentFormat" value="CHECKSTYLE DISABLE ([\w\|]+) FOR (-?\d+) LINES"/>
<property name="checkFormat" value="$1"/>
<property name="influenceFormat" value="$2"/>
</module>
On the line where you want to disable the warning you can write:
// CHECKSTYLE DISABLE <WarningName> FOR <# of lines> LINES
for example
// CHECKSTYLE DISABLE MagicNumber FOR 2 LINES
The number can also be negative (if the warning is in some automatically generated code that you cannot touch).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With