Class RegexpSinglelineCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck
- All Implemented Interfaces:
Configurable
,Contextualizable
,FileSetCheck
Checks that a specified pattern matches a single-line in any file type.
Rationale: This check can be used to prototype checks and to find common bad
practice such as calling ex.printStacktrace()
,
System.out.println()
, System.exit()
, etc.
-
Property
fileExtensions
- Specify the file extensions of the files to process. Type isjava.lang.String[]
. Default value is""
. -
Property
format
- Specify the format of the regular expression to match. Type isjava.util.regex.Pattern
. Default value is"$."
. -
Property
ignoreCase
- Control whether to ignore case when searching. Type isboolean
. Default value isfalse
. -
Property
maximum
- Specify the maximum number of matches required in each file. Type isint
. Default value is0
. -
Property
message
- Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used. Type isjava.lang.String
. Default value isnull
. -
Property
minimum
- Specify the minimum number of matches required in each file. Type isint
. Default value is0
.
Parent is com.puppycrawl.tools.checkstyle.Checker
Violation Message Keys:
-
regexp.exceeded
-
regexp.minimum
- Since:
- 5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions
-
Field Summary
Modifier and TypeFieldDescriptionprivate SinglelineDetector
The detector to use.private String
Specify the format of the regular expression to match.private boolean
Control whether to ignore case when searching.private int
Specify the maximum number of matches required in each file.private String
Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.private int
Specify the minimum number of matches required in each file. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
beginProcessing
(String charset) Called when about to be called to process a set of files.protected void
processFiltered
(File file, FileText fileText) Called to process a file that matches the specified file extensions.void
Setter to specify the format of the regular expression to match.void
setIgnoreCase
(boolean ignoreCase) Setter to control whether to ignore case when searching.void
setMaximum
(int maximum) Setter to specify the maximum number of matches required in each file.void
setMessage
(String message) Setter to specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.void
setMinimum
(int minimum) Setter to specify the minimum number of matches required in each file.Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
addViolations, destroy, finishProcessing, fireErrors, getFileContents, getFileExtensions, getMessageDispatcher, getTabWidth, getViolations, init, log, log, process, setFileContents, setFileExtensions, setMessageDispatcher, setTabWidth
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Configurable
configure
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Contextualizable
contextualize
-
Field Details
-
format
Specify the format of the regular expression to match. -
message
Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used. -
minimum
Specify the minimum number of matches required in each file. -
maximum
Specify the maximum number of matches required in each file. -
ignoreCase
Control whether to ignore case when searching. -
detector
The detector to use.
-
-
Constructor Details
-
RegexpSinglelineCheck
public RegexpSinglelineCheck()
-
-
Method Details
-
beginProcessing
Description copied from interface:FileSetCheck
Called when about to be called to process a set of files.- Specified by:
beginProcessing
in interfaceFileSetCheck
- Overrides:
beginProcessing
in classAbstractFileSetCheck
- Parameters:
charset
- the character set used to read the files.
-
processFiltered
Description copied from class:AbstractFileSetCheck
Called to process a file that matches the specified file extensions.- Specified by:
processFiltered
in classAbstractFileSetCheck
- Parameters:
file
- the file to be processedfileText
- the contents of the file.
-
setFormat
Setter to specify the format of the regular expression to match.- Parameters:
format
- the format of the regular expression to match.- Since:
- 5.0
-
setMessage
Setter to specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.- Parameters:
message
- the message to report for a match.- Since:
- 5.0
-
setMinimum
Setter to specify the minimum number of matches required in each file.- Parameters:
minimum
- the minimum number of matches required in each file.- Since:
- 5.0
-
setMaximum
Setter to specify the maximum number of matches required in each file.- Parameters:
maximum
- the maximum number of matches required in each file.- Since:
- 5.0
-
setIgnoreCase
Setter to control whether to ignore case when searching.- Parameters:
ignoreCase
- whether to ignore case when searching.- Since:
- 5.0
-