public final class BeforeExecutionExclusionFileFilter extends AutomaticBean implements BeforeExecutionFileFilter
BeforeExecutionExclusionFileFilter decides which files should be
excluded from being processed by the utility.
By default Checkstyle includes all files and sub-directories in a directory to be processed and
checked for violations. Users could have files that are in these sub-directories that shouldn't
be processed with their checkstyle configuration for various reasons, one of which is a valid
Java file that won't pass Checkstyle's parser. When Checkstyle tries to parse a Java file and
fails, it will throw an
Exception and halt parsing any more files for violations.
An example of a valid Java file Checkstyle can't parse is JDK 9's
This file filter will exclude these problem files from being parsed, allowing the rest of the
files to run normal and be validated.
Note: When a file is excluded from the utility, it is excluded from all Checks and no testing for violations will be performed on them.
fileNamePattern- Define regular expression to match the file name against. Type is
java.util.regex.Pattern. Default value is
To configure the filter to exclude all 'module-info.java' files:
<module name="BeforeExecutionExclusionFileFilter"> <property name="fileNamePattern" value="module\-info\.java$"/> </module>
To configure the filter to run only on required files for example that ends with "Remote" or end with "Client" in names or named as "Remote.java" or "Client.java" use negative lookahead:
<module name="BeforeExecutionExclusionFileFilter"> <property name="fileNamePattern" value="^(?!.*(Remote\.java|Client\.java|[\\/]Remote\.java|[\\/]Client\.java)).*$"/> </module>
To configure the filter to exclude all Test folder files:
<module name="BeforeExecutionExclusionFileFilter"> <property name="fileNamePattern" value=".*[\\/]src[\\/]test[\\/].*$"/> </module>
|Modifier and Type||Field and Description|
Define regular expression to match the file name against.
|Constructor and Description|
|Modifier and Type||Method and Description|
Determines whether or not a before execution file filtered event is accepted.
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.
Setter to define regular expression to match the file name against.
configure, contextualize, getConfiguration, setupChild
public void setFileNamePattern(Pattern fileNamePattern)
fileNamePattern- regular expression of the excluded file.
protected void finishLocalSetup()
The default implementation does nothing.
Copyright © 2001–2021. All rights reserved.