I'm trying have Checkstyle be given any file type, but ignore anything that is not a .java file. I created a filter, but that doesn't seem to be working:
public class DotJavaFilter
extends AutomaticBean
implements Filter
{
public DotJavaFilter()
throws PatternSyntaxException
{
}
public boolean accept(AuditEvent aEvent)
{
final String fileName = aEvent.getFileName();
return fileName.endsWith(".java");
}
}
I'd like to give CS a directory of files and have it only process the .java ones.
You can run it on the command line like this:
java -jar checkstyle-5.5-all.jar -c docs/sun_checks.xml -r /path/to/src
If you are using bash, you can turn on globstar
and then process only java files like this:
shopt -s globstar
java -jar checkstyle-5.5-all.jar -c docs/sun_checks.xml -r /path/to/src/**/*.java
Checkstyle command line documentation is here.
Update: Using a suppression filter
Create a suppressions file which to ignore all checks on class files. You can add regexes for other file types you are not interested as well.
suppressions.xml:
<suppressions>
<suppress checks="." files=".*\.class"/>
</suppressions>
Add a suppression filter to your checks file:
my_checks.xml:
<module name="SuppressionFilter">
<property name="file" value="suppressions.xml"/>
</module>
Run it:
java -jar checkstyle-5.5-all.jar -c my_checks.xml -r /path/to/src
Documentation on Suppression Filters can be found here.
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