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, setTabWidthfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconfigurecontextualizepublic static final String MSG_KEY
public FileLengthCheck()
protected void processFiltered(File file, FileText fileText)
AbstractFileSetCheckprocessFiltered in class AbstractFileSetCheckfile - 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.