diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/java.g b/src/checkstyle/com/puppycrawl/tools/checkstyle/java.g index a7d805fb6..01fd1264d 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/java.g +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/java.g @@ -506,8 +506,8 @@ statement // For statement | "for"^ LPAREN! - forInit SEMI! // initializer - forCond SEMI! // condition test + forInit s1:SEMI! {ver.verifyWSAfter(s1.getLine(), s1.getColumn(), "';'");} // initializer + forCond s2:SEMI! {ver.verifyWSAfter(s2.getLine(), s2.getColumn(), "';'");} // condition test forIter // updater RPAREN! statement // statement to loop over diff --git a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java index 86019c0de..71cfb8f28 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java @@ -133,20 +133,22 @@ public class CheckerTest filepath + ":42: 'while' construct must use '{}'s.", filepath + ":44: 'while' construct must use '{}'s.", filepath + ":45: 'if' construct must use '{}'s.", + filepath + ":58: ';' needs to be followed by whitespace.", + filepath + ":58: ';' needs to be followed by whitespace.", filepath + ":58: 'for' construct must use '{}'s.", filepath + ":58: ';' is not preceeded with whitespace.", filepath + ":59: 'for' construct must use '{}'s.", filepath + ":61: 'for' construct must use '{}'s.", - filepath + ":62: 'if' construct must use '{}'s.", - filepath + ":81: 'if' construct must use '{}'s.", - filepath + ":81: ';' is not preceeded with whitespace.", + filepath + ":63: 'if' construct must use '{}'s.", filepath + ":82: 'if' construct must use '{}'s.", - filepath + ":84: 'if' construct must use '{}'s.", - filepath + ":84: 'else' construct must use '{}'s.", - filepath + ":88: 'if' construct must use '{}'s.", - filepath + ":93: 'else' construct must use '{}'s.", - filepath + ":98: 'if' construct must use '{}'s.", - filepath + ":99: 'if' construct must use '{}'s." + filepath + ":82: ';' is not preceeded with whitespace.", + filepath + ":83: 'if' construct must use '{}'s.", + filepath + ":85: 'if' construct must use '{}'s.", + filepath + ":85: 'else' construct must use '{}'s.", + filepath + ":89: 'if' construct must use '{}'s.", + filepath + ":94: 'else' construct must use '{}'s.", + filepath + ":99: 'if' construct must use '{}'s.", + filepath + ":100: 'if' construct must use '{}'s." }; verify(c, filepath, expected); } @@ -159,8 +161,10 @@ public class CheckerTest final String filepath = getPath("InputBraces.java"); final String[] expected = { filepath + ":41: ';' is not preceeded with whitespace.", + filepath + ":58: ';' needs to be followed by whitespace.", + filepath + ":58: ';' needs to be followed by whitespace.", filepath + ":58: ';' is not preceeded with whitespace.", - filepath + ":81: ';' is not preceeded with whitespace.", + filepath + ":82: ';' is not preceeded with whitespace.", }; verify(c, filepath, expected); } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/InputBraces.java b/src/tests/com/puppycrawl/tools/checkstyle/InputBraces.java index 7fc17bff2..210b9e6d9 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/InputBraces.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/InputBraces.java @@ -55,10 +55,11 @@ class InputBraces } // Invalid - for (int i = 1; i < 5; i++); + for (int i = 1;i < 5;i++); for (int i = 1; i < 5; i++) testFor(); - for (int i = 1; i < 5; i++) + for (int i = 1; i < 5; + i++) if (i > 2) testFor(); }