How can you suppress check checks in a code block only for certain rules?

Possible duplicate:
How to disable a specific validation rule for a specific line of code?

When disabling Checkstyle, there is a syntax for the code segment that suppresses only certain checks.

Therefore, not just

// CHECKSTYLE: OFF
the code
// CHECKSTYLE: ON

you might have something like

// CHECKSTYLE: OFF: RequireThis,
the code
// CHECKSTYLE: ON

In cases where we intentionally make an exception for a style, it would be nice to be clearer about what the exception case is.

+6
checkstyle suppression
source share
1 answer

We recommend reading the documentation on the SuppressionCommentFilter (it looks like a bit) for many examples.

Example filter settings:

<module name="SuppressionCommentFilter"> <property name="offCommentFormat" value="CSOFF\: ([\w\|]+)"/> <property name="onCommentFormat" value="CSON\: ([\w\|]+)"/> <property name="checkFormat" value="$1"/> </module> 

You can then use the following to disable RequireThis validation for a block of code:

 // CSOFF: RequireThis ... code // CSON: RequireThis 
+7
source share

All Articles