public class FileLengthCheck extends AbstractFileSetCheck
Checks for long source files.
Rationale: If a source file becomes very long it is hard to understand. Therefore long classes should usually be refactored into several individual classes that focus on a specific task.
max
- Specify the maximum number of lines allowed.
Type is int
.
Default value is 2000
.
fileExtensions
- Specify the file type extension of files to process.
Type is java.lang.String[]
.
Default value is all files
.
To configure the check:
<module name="FileLength"/>
To configure the check to accept files with up to 1500 lines:
<module name="FileLength"> <property name="max" value="1500"/> </module>
Parent is com.puppycrawl.tools.checkstyle.Checker
Violation Message Keys:
maxLen.file
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 |
---|
FileLengthCheck() |
Modifier and Type | Method and Description |
---|---|
protected void |
processFiltered(File file,
FileText fileText)
Called to process a file that matches the specified file extensions.
|
void |
setMax(int length)
Setter to specify the maximum number of lines allowed.
|
addMessages, beginProcessing, destroy, finishProcessing, fireErrors, getFileContents, getFileExtensions, getMessageDispatcher, getMessages, getTabWidth, init, log, log, process, setFileContents, setFileExtensions, setMessageDispatcher, setTabWidth
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
configure, contextualize, getConfiguration, setupChild
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
configure
contextualize
public static final String MSG_KEY
public FileLengthCheck()
protected void processFiltered(File file, FileText fileText)
AbstractFileSetCheck
processFiltered
in class AbstractFileSetCheck
file
- the file to be processedfileText
- the contents of the file.public void setMax(int length)
length
- the maximum length of a Java source fileCopyright © 2001–2020. All rights reserved.