Field naming convention
Reports fields whose names are too short, too long, or do not follow the specified regular expression pattern.
Example: if the inspection is enabled for constants, and the minimum specified length for a field name is 5 (the default), the following constant produces a warning because the length of its name is 3, which is less than 5: public static final int MAX = 42;
.
A quick-fix that renames such fields is available only in the editor.
Configure the inspection:
Use the list in the Options section to specify which fields should be checked. Deselect the checkboxes for the fields for which you want to skip the check.
For each field type, specify the minimum length, maximum length, and the regular expression expected for field names using the provided input fields. Specify 0 in the length fields to skip the corresponding checks.
Regular expressions should be specified in the standard java.util.regex
format.
Inspection options
Option | Type | Default |
---|---|---|
CheckboxPanel | None | |
Instance field | Checkbox | false |
Pattern | String | m_[a-z][A-Za-z\d]* |
Min length | Number | 5 |
Max length | Number | 32 |
'static' field | Checkbox | false |
Pattern | String | [A-Z][A-Z_\d]* |
Min length | Number | 5 |
Max length | Number | 32 |
Constant | Checkbox | false |
Pattern | String | [A-Z][A-Z_\d]* |
Min length | Number | 5 |
Max length | Number | 32 |
Constant with mutable type | Checkbox | false |
Pattern | String | [A-Z][A-Z_\d]* |
Min length | Number | 5 |
Max length | Number | 32 |
Enum constant | Checkbox | false |
Pattern | String | [A-Z][A-Z_\d]* |
Min length | Number | 5 |
Max length | Number | 32 |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |