Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using the marker // CHECKSTYLE:OFF: FileLength does not seem to work #5575

Closed
thehcma opened this issue Mar 2, 2018 · 4 comments
Closed

Comments

@thehcma
Copy link

thehcma commented Mar 2, 2018

When attempting to disable the FileLength check for a file, checkstyle 8.7 still emits an error:

Starting audit...
[ERROR] TestFile.java:1: File length is 2,219 lines (max allowed is 2,000). [FileLength]
Audit done.
Checkstyle ends with 1 errors.

Note that the file has the marker

$ head TestFile.java
// CHECKSTYLE:OFF: FileLength

Our checkstyle configuration is attached.

checkstyle.zip

Running checkstyle as follows:

<path>/server-jre-1.8.0_152/bin/java -jar <checkstyle-path>/checkstyle-8.7-all.jar -c <config-path>/sun_checks.xml TestFile.java
@rnveach
Copy link
Member

rnveach commented Mar 2, 2018

FileLength is a Checker check and SuppressionCommentFilter is a TreeWalker filter.
Since SuppressionCommentFilter is in TreeWalker, it means it can only suppress violations from other checks inside TreeWalker.

You must define a suppression configuration with SuppressWithPlainTextCommentFilter, which is a Checker filter, to suppress violations from FileLength. It takes the same options as SuppressionCommentFilter so you should be able to just copy the old and rename the module.

@thehcma
Copy link
Author

thehcma commented Mar 2, 2018

Yup, that was it. Thanks @rnveach.

Closing.

@thehcma thehcma closed this as completed Mar 2, 2018
@geofflangenderfer
Copy link

@thehcma or @rnveach could you give a minimal example? I'm struggling with this

@romani
Copy link
Member

romani commented Apr 13, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants