FileLength

Since Checkstyle 5.0

Description

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.

Properties

name description type default value since
max Specify the maximum number of lines allowed. int 2000 3.2
fileExtensions Specify the file type extension of files to process. String[] all files 5.0

Examples

To configure the check:

<module name="Checker">
  <module name="FileLength"/>
</module>
        

To configure the check to accept files with up to 1500 lines:

<module name="Checker">
  <module name="FileLength">
    <property name="max" value="1500"/>
  </module>
</module>
        

Example of Usage

Violation Messages

All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.

Package

com.puppycrawl.tools.checkstyle.checks.sizes

Parent Module

Checker