Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
408 views
in Technique[技术] by (71.8m points)

java - How to suppress all checks for a file in Checkstyle?

I'm doing an override for a third party class and I want to suppress all checks for it (since I'm only keeping it around until the patch is accepted).

Is there a way to suppress all checks for a file?

I tried using "*" but that fails.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Don't know whether you're using command line or in an IDE, but you'll basically need a suppresions file. If you're manually editing the Checkstyle config file, add a new module to it:

<module name="SuppressionFilter">
    <property name="file" value="mysuppressions.xml" />
</module>

Your mysuppression.xml can be something like:

<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
    "-//Puppy Crawl//DTD Suppressions 1.1//EN"
    "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
    <suppress files="TheClassToIgnore.java" checks="[a-zA-Z0-9]*"/>
</suppressions>

The value for "files" attribute is basically a regex for your source files, and the value for the "checks" attribute is regex for what checks to skip ("[a-zA-Z0-9]*" basically means skip everything). This is the pattern you're looking for I guess?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...