Class BeforeExecutionExclusionFileFilter
- All Implemented Interfaces:
BeforeExecutionFileFilter
,Configurable
,Contextualizable
BeforeExecutionExclusionFileFilter
decides which files should be
excluded from being processed by the utility.
By default, Checkstyle includes all files and subdirectories in a directory to be processed and
checked for violations. Users could have files that are in these subdirectories 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 module-info.java
.
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.
-
Property
fileNamePattern
- Define regular expression to match the file name against. Type isjava.util.regex.Pattern
. Default value isnull
.
Parent is com.puppycrawl.tools.checkstyle.Checker
- Since:
- 7.2
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Pattern
Define regular expression to match the file name against. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines whether or not a before execution file filtered event is accepted.protected void
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.void
setFileNamePattern
(Pattern fileNamePattern) Setter to define regular expression to match the file name against.Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
Field Details
-
fileNamePattern
Define regular expression to match the file name against.
-
-
Constructor Details
-
BeforeExecutionExclusionFileFilter
public BeforeExecutionExclusionFileFilter()
-
-
Method Details
-
setFileNamePattern
Setter to define regular expression to match the file name against.- Parameters:
fileNamePattern
- regular expression of the excluded file.- Since:
- 7.2
-
finishLocalSetup
Description copied from class:AbstractAutomaticBean
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.The default implementation does nothing.
- Specified by:
finishLocalSetup
in classAbstractAutomaticBean
-
accept
Description copied from interface:BeforeExecutionFileFilter
Determines whether or not a before execution file filtered event is accepted.- Specified by:
accept
in interfaceBeforeExecutionFileFilter
- Parameters:
uri
- the uri to filter.- Returns:
- true if the event is accepted.
-