Since Checkstyle 5.0
name | description | type | default value | since |
---|---|---|---|---|
format | Sets the pattern to match valid identifiers. | Pattern | "^[A-Z]$" |
5.0 |
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="MethodTypeParameterName"/> </module> </module>
Code Example:
class Example1 { public <T> void method1() {} public <a> void method2() {} // violation public <K, V> void method3() {} public <k, V> void method4() {} // violation }
An example of how to configure the check for names that are only a single letter is:
<module name="Checker"> <module name="TreeWalker"> <module name="MethodTypeParameterName"> <property name="format" value="^[a-zA-Z]$"/> </module> </module> </module>
Code Example:
class Example2 { public <T> void method1() {} public <a> void method2() {} public <K, V> void method3() {} public <k, V> void method4() {} }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.naming