Static Final Fields Should Be UPPER_SNAKE_CASE
ID |
java.naming_static_final_lowercase |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Naming Convention |
Language |
Java |
Tags |
naming |
Description
Reports static final fields whose names contain lowercase letters. Constants should use the UPPER_SNAKE_CASE convention. Interface fields, which are implicitly static final, are also checked.
Logger field names (log, logger) are excluded by default, as the lowercase convention for loggers is universally accepted.
Configuration
| Property | Default | Description |
|---|---|---|
|
|
Additional field names to allow in lowercase. Merged with the built-in whitelist. |
Rationale
The UPPER_SNAKE_CASE convention for constants is a universal Java idiom. It signals at a glance that a value is immutable and shared. Lowercase in a constant name looks like a mutable variable and confuses readers.
// Bad
public static final int size = 10;
// Good
public static final int SIZE = 10;