Skip to content

Files

Latest commit

 

History

History
45 lines (27 loc) · 1.01 KB

MethodLength.md

File metadata and controls

45 lines (27 loc) · 1.01 KB

Pattern: Method is too long

Issue: -

Description

Checks for long methods and constructors.

Rationale: If a method becomes very long it is hard to understand. Therefore long methods should usually be refactored into several individual methods that focus on a specific task.

Examples

To configure the check:

<module name="MethodLength"/>

To configure the check so that it accepts methods with at most 60 lines:

<module name="MethodLength">
   <property name="tokens" value="METHOD_DEF"/>
   <property name="max" value="60"/>
</module>

To configure the check so that it accepts methods with at most 60 lines, not counting empty lines and single line comments:

<module name="MethodLength">
   <property name="tokens" value="METHOD_DEF"/>
   <property name="max" value="60"/>
   <property name="countEmpty" value="false"/>
</module>

Further Reading