ExecutableStatementCount

Since Checkstyle 3.2

Description

Restricts the number of executable statements to a specified limit.

Properties

name description type default value since
max Specify the maximum threshold allowed. int 30 3.2
tokens tokens to check subset of tokens CTOR_DEF , METHOD_DEF , INSTANCE_INIT , STATIC_INIT , COMPACT_CTOR_DEF , LAMBDA . CTOR_DEF , METHOD_DEF , INSTANCE_INIT , STATIC_INIT , COMPACT_CTOR_DEF , LAMBDA . 3.2

Examples

To configure the check:

<module name="Checker">
  <module name="TreeWalker">
    <module name="ExecutableStatementCount"/>
  </module>
</module>
        

To configure the check with a threshold of 20 for constructor and method definitions:

<module name="Checker">
  <module name="TreeWalker">
    <module name="ExecutableStatementCount">
      <property name="max" value="20"/>
      <property name="tokens" value="CTOR_DEF,METHOD_DEF"/>
    </module>
  </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

TreeWalker