Since Checkstyle 8.36
name | description | type | default value | since |
---|---|---|---|---|
format | Sets the pattern to match valid identifiers. | Pattern | "^[A-Z]$" |
8.36 |
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="RecordTypeParameterName"/> </module> </module>
Example:
class Example1 { record Record1<T>() {} record Record2<t>() {} // violation, Name "t" must match pattern '^[A-Z]$' record Record3<abc>() {} // violation, Name "abc" must match pattern '^[A-Z]$' }
An example of how to configure the check for names that are only a single letter is:
Configuration:
<module name="Checker"> <module name="TreeWalker"> <module name="RecordTypeParameterName"> <property name="format" value="^[a-zA-Z]$"/> </module> </module> </module>
Example:
class Example2 { record Record1<T>() {} record Record2<t>() {} record Record3<abc>() {} // violation, Name "abc" must match pattern '^[A-Z]$' }
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