array-bracket-space
What it does
Section titled “What it does”Reports an array creation in which the { of the initializer follows the ] right away (new int[]{1}).
Why it matters
Section titled “Why it matters”The space between the brackets and the braces is the convention of the Java code style guides, and it separates the type from the initializer so that new int[] {1} reads as two parts.
To fix, put a space between ] and {.
Example
Section titled “Example”class A { Object a = new int[]{1}; Object b = new int[] {1}; Object c = new String[]{"a]{"}; Object d = new int[2]; int[] e = {1};}Configuration
Section titled “Configuration”java: lint: rules: array-bracket-space: warn # off (default), warn, errorEnabled by the presets: java/google.
Suppress one line with sudsy-disable-next-line array-bracket-space 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 | ArrayBracketNoWhitespace |
partial | Only the { of an array creation right after the ]. |