Skip to content

Commit

Permalink
Issue checkstyle#8122: Google style should enforce space around enhan…
Browse files Browse the repository at this point in the history
…ced for colon
  • Loading branch information
shashwatj07 committed Sep 2, 2020
1 parent e40c8b9 commit fafaa40
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<suppressions>
<!-- can't split long messages between lines -->
<suppress checks="RegexpSingleline" files="google_checks\.xml" lines="56,125"/>
<suppress checks="RegexpSingleline" files="google_checks\.xml" lines="56,126"/>
<!-- don't validate generated files -->
<suppress checks="RegexpSingleline" files="releasenotes\.xml"/>
<suppress checks="RegexpSingleline" files="[\\/]meta[\\/]"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ public void testWhitespaceAroundBasic() throws Exception {
"118:19: " + getCheckMessage(messages, msgFollowed, "/"),
"147:9: " + getCheckMessage(messages, msgFollowed, "assert"),
"150:20: " + getCheckMessage(messages, msgPreceded, ":"),
"249:14: " + getCheckMessage(messages, msgPreceded, "->"),
"250:15: " + getCheckMessage(messages, msgFollowed, "->"),
"241:19: " + getCheckMessage(messages, msgFollowed, ":"),
"241:19: " + getCheckMessage(messages, msgPreceded, ":"),
"242:20: " + getCheckMessage(messages, msgFollowed, ":"),
"243:19: " + getCheckMessage(messages, msgPreceded, ":"),
"257:14: " + getCheckMessage(messages, msgPreceded, "->"),
"258:15: " + getCheckMessage(messages, msgFollowed, "->"),
};

final String filePath = getPath("InputWhitespaceAroundBasic.java");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ int[] getSomeInts() {
int i = (int) ( 2 / 3 );
return null;
}

void forColon() {
int ll[] = new int[10];
for (int x:ll) {} // warn
for (int x :ll) {} // warn
for (int x: ll) {} // warn
for (int x : ll) {} // ok
}
}

/**
Expand Down
11 changes: 6 additions & 5 deletions src/main/resources/google_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,19 @@
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<property name="ignoreEnhancedForColon" value="false"/>
<property name="tokens"
value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR,
BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND,
LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY,
LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED,
LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN,
NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR,
SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN,
NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR,
SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
Expand Down

0 comments on commit fafaa40

Please sign in to comment.