Class LineLengthExtendedCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.github.sevntu.checkstyle.checks.sizes.LineLengthExtendedCheck
-
- All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable
,com.puppycrawl.tools.checkstyle.api.Contextualizable
public class LineLengthExtendedCheck extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
Checks for long lines.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.
Note: Support for the special handling of imports in CheckStyle Version 2 has been dropped as it is a special case of regexp: The user can set the ignorePattern to "^import" and achieve the same effect.
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>
There are some exceptions for class, constructor, field and method declarations. To ignore to check such lines there are enable|disable options. By default they have "false" values.
- Since:
- 1.5.1
- Author:
- Lars Kühne, Ruslan Dyachenko
-
-
Constructor Summary
Constructors Constructor Description LineLengthExtendedCheck()
Creates a newLineLengthCheck
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginTree(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
void
finishTree(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
int[]
getAcceptableTokens()
int[]
getDefaultTokens()
int[]
getRequiredTokens()
void
setIgnoreClass(boolean value)
Enable|Disable checking class declaration length.void
setIgnoreConstructor(boolean value)
Enable|Disable checking constructor declaration length.void
setIgnoreField(boolean value)
Enable|Disable checking field declaration length.void
setIgnoreMethod(boolean value)
Enable|Disable checking method declaration length.void
setIgnorePattern(String format)
Set the ignore pattern.void
setMax(int length)
Setter for the field max.void
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearViolations, destroy, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
-
-
-
Field Detail
-
MSG_KEY
public static final String MSG_KEY
Warning message key.- See Also:
- Constant Field Values
-
-
Method Detail
-
setIgnoreField
public void setIgnoreField(boolean value)
Enable|Disable checking field declaration length.- Parameters:
value
- check field declaration length.
-
setIgnoreMethod
public void setIgnoreMethod(boolean value)
Enable|Disable checking method declaration length.- Parameters:
value
- check method declaration length.
-
setIgnoreConstructor
public void setIgnoreConstructor(boolean value)
Enable|Disable checking constructor declaration length.- Parameters:
value
- check constructor declaration length.
-
setIgnoreClass
public void setIgnoreClass(boolean value)
Enable|Disable checking class declaration length.- Parameters:
value
- check class declaration length.
-
getDefaultTokens
public int[] getDefaultTokens()
- Specified by:
getDefaultTokens
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getAcceptableTokens
public int[] getAcceptableTokens()
- Specified by:
getAcceptableTokens
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getRequiredTokens
public int[] getRequiredTokens()
- Specified by:
getRequiredTokens
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
- Overrides:
visitToken
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
beginTree
public void beginTree(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
- Overrides:
beginTree
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
finishTree
public void finishTree(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
- Overrides:
finishTree
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
setMax
public void setMax(int length)
Setter for the field max.- Parameters:
length
- the maximum length of a line
-
setIgnorePattern
public final void setIgnorePattern(String format)
Set the ignore pattern.- Parameters:
format
- aString
value- Throws:
IllegalArgumentException
- unable to parse aFormat
-
-