public class LineLengthCheck extends AbstractCheck
Rationale: Long lines are hard to read in printouts or if developers have limited screen space for the source code, e.g. if the IDE displays additional information like project tree, class hierarchy, etc.
Package statements and import statements (lines matching pattern
^(package|import) .*
), and are not verified by this check.
The default maximum allowable line length is 80 characters. To change the maximum, set property max.
To ignore lines in the check, set property ignorePattern to a regular expression for the lines to ignore.
An example of how to configure the check is:
<module name="LineLength"/>
An example of how to configure the check to accept lines up to 120 characters long is:
<module name="LineLength"> <property name="max" value="120"/> </module>
An example of how to configure the check to ignore lines that begin with " * ", followed by just one word, such as within a Javadoc comment, is:
<module name="LineLength"> <property name="ignorePattern" value="^ *\* *[^ ]+$"/> </module>
AutomaticBean.OutputStreamOptions
Modifier and Type | Field and Description |
---|---|
static String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
Constructor and Description |
---|
LineLengthCheck() |
Modifier and Type | Method and Description |
---|---|
void |
beginTree(DetailAST rootAST)
Called before the starting to process a tree.
|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
setIgnorePattern(Pattern pattern)
Set the ignore pattern.
|
void |
setMax(int length)
Sets the maximum length of a line.
|
clearMessages, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setClassLoader, setFileContents, setTabWidth, setTokens, visitToken
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
configure, contextualize, getConfiguration, setupChild
public static final String MSG_KEY
public LineLengthCheck()
public int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void beginTree(DetailAST rootAST)
AbstractCheck
beginTree
in class AbstractCheck
rootAST
- the root of the treepublic void setMax(int length)
length
- the maximum length of a linepublic final void setIgnorePattern(Pattern pattern)
pattern
- a pattern.Copyright © 2001–2018. All rights reserved.