I have a java class with > 2000 lines, and I have Checkstyle configured to allow lines upto 2000. I want to override this Checkstyle property only for one file. How can I do that?
-
1Possible duplicate of stackoverflow.com/questions/4023185/…Monzurul Shimul– Monzurul Shimul2017-01-27 04:34:46 +00:00Commented Jan 27, 2017 at 4:34
-
3Possible duplicate of How to disable a particular checkstyle rule for a particular line of code?Nikhil Girraj– Nikhil Girraj2017-01-27 07:01:15 +00:00Commented Jan 27, 2017 at 7:01
Add a comment
|
2 Answers
In Checkstyle code itself there is TokenTypes class that is huge.
Solution that Checkstyle developers use currently is to suppress that file by specifying it in suppressions.xml:
<suppressions>
<suppress checks="FileLength"
files="TokenTypes.java"
lines="1"/>
This mechanism is called SuppressionFilter.
2 Comments
Geoff Langenderfer
what does
lines="1" do?Pnar Sbi Wer
the
lines is intended to target what line the error is appearing on. In this case, it isn't required. See checkstyle.sourceforge.io/apidocs/com/puppycrawl/tools/…Just place this comment as the very first line of your class file:
// CSOFF: FileLength
1 Comment
Nagy Attila
This is a good answer, but in order to work you should configure
SuppressionCommentFilter with offCommentFormat and onCommentFormat, or you can use directly the default values with CHECKSTYLE:OFF and CHECKSTYLE:ON instead the CSOFF value. See checkstyle.sourceforge.io/filters/suppressioncommentfilter.html