A declaration is named with a word that later Java versions made a keyword
What it finds
var, yield, record, sealed, permits and when became keywords in some places of the language after Java 8, and stay names everywhere else. Code that declares a variable, method or field with one of them is confusing to read, and some uses stop compiling: a method named yield cannot be called without a qualifier, and a type named var or record cannot be declared at all.
From the rule's source, keyword_as_name.rs.
class Records { int record;tx0 reports: record is a keyword in parts of the language void yield() {}tx0 reports: yield is a keyword void read() { var value = 1; int var = value;tx0 reports: var is a keyword }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:contextual-keyword-name" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:contextual-keyword-name] reason="..."tx0 explain tx0/java:contextual-keyword-name shows the same in the terminal. Found a false positive? Report it.