abbreviation-in-name
What it does
Section titled “What it does”Reports a name with two or more capital letters in a row (XMLParser), for type, method, parameter, field and local variable names that match the names option. Names that match ignored (constants and overridden methods by default) are not reported. With an empty names the rule checks nothing.
Why it matters
Section titled “Why it matters”A run of capitals hides where one word ends and the next starts: XMLHTTPRequest does not show if it is XML HTTP or XMLH TTP, and tools that split names into words get it wrong. Treating an abbreviation as a word (XmlHttpRequest) keeps the name readable and its camel case regular.
To fix, write the abbreviation as a word: XmlParser.
Example
Section titled “Example”class XMLParser { static final int MAX_SIZE = 1; int fooBAR; int goodName; int endsWithB;
void getURL(int httpID) { int myURL = 1; int fine = 2; }
...Configuration
Section titled “Configuration”java: lint: rules: abbreviation-in-name: level: warn # off (default), warn, error options: names: "" ignored: "^.*$"| Option | Type | Default | Description |
|---|---|---|---|
names |
string | "" |
Regular expression a type, method, parameter, field or local variable name must match; empty: not checked. |
ignored |
string | "^.*$" |
Regular expression matched for the names that are left out (constants, overridden methods): every name by default. |
Enabled by the presets: java/google.
Suppress one line with sudsy-disable-next-line abbreviation-in-name in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| checkstyle | AbbreviationAsWordInName |
partial | Only more than one capital in a row; no allowed length or ignore options. |