diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/ArrayInitHandler.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/ArrayInitHandler.java index 3deac47ce..49c0f226f 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/ArrayInitHandler.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/ArrayInitHandler.java @@ -77,11 +77,6 @@ public class ArrayInitHandler extends BlockParentHandler { return getMainAst().findFirstToken(TokenTypes.RCURLY); } - @Override - protected boolean shouldStartWithRCurly() { - return false; - } - @Override protected boolean canChildrenBeNested() { return true; diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/BlockParentHandler.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/BlockParentHandler.java index e86f50177..3f55957cd 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/BlockParentHandler.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/BlockParentHandler.java @@ -170,15 +170,6 @@ public class BlockParentHandler extends AbstractExpressionHandler { return new IndentLevel(getIndent(), getBraceAdjustment()); } - /** - * Determines if the right curly brace must be at the start of the line. - * - * @return true - */ - protected boolean shouldStartWithRCurly() { - return true; - } - /** * Determines if child elements within the expression may be nested. * @@ -192,15 +183,11 @@ public class BlockParentHandler extends AbstractExpressionHandler { * Check the indentation of the right curly brace. */ protected void checkRCurly() { - // the rcurly can either be at the correct indentation, or - // on the same line as the lcurly - final DetailAST lcurly = getLCurly(); final DetailAST rcurly = getRCurly(); final int rcurlyPos = expandedTabsColumnNo(rcurly); if (!curlyIndent().isAcceptable(rcurlyPos) - && (shouldStartWithRCurly() || isOnStartOfLine(rcurly)) - && !areOnSameLine(rcurly, lcurly)) { + && isOnStartOfLine(rcurly)) { logError(rcurly, "rcurly", rcurlyPos, curlyIndent()); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java index c4f496926..478583417 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java @@ -1039,7 +1039,6 @@ public class IndentationCheckTest extends BaseCheckTestSupport { "225: " + getCheckMessage(MSG_ERROR, "if", 10, 12), "229: " + getCheckMessage(MSG_CHILD_ERROR, "if", 18, 20), - "233: " + getCheckMessage(MSG_ERROR, "if rcurly", 40, 8), "240: " + getCheckMessage(MSG_ERROR, "if rparen", 10, 8), "245: " + getCheckMessage(MSG_ERROR, "if rparen", 6, 8), "251: " + getCheckMessage(MSG_ERROR, "if lparen", 6, 8), @@ -1112,9 +1111,7 @@ public class IndentationCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("tabWidth", "4"); checkConfig.addAttribute("throwsIndent", "4"); final String fileName = getPath("InputInvalidAnonymousClassIndent.java"); - final String[] expected = { - "28: " + getCheckMessage(MSG_ERROR_MULTI, "method def rcurly", 17, "12, 16"), - }; + final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; verifyWarns(checkConfig, fileName, expected); } @@ -1153,7 +1150,6 @@ public class IndentationCheckTest extends BaseCheckTestSupport { "70: " + getCheckMessage(MSG_CHILD_ERROR, "for", 10, 12), "71: " + getCheckMessage(MSG_CHILD_ERROR, "for", 14, 16), "72: " + getCheckMessage(MSG_CHILD_ERROR, "for", 10, 12), - "77: " + getCheckMessage(MSG_ERROR, "for rcurly", 39, 8), "81: " + getCheckMessage(MSG_ERROR, "for rparen", 12, 8), }; verifyWarns(checkConfig, fileName, expected); diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidAnonymousClassIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidAnonymousClassIndent.java index 5e84c1e64..b2d5e7e85 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidAnonymousClassIndent.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidAnonymousClassIndent.java @@ -25,7 +25,7 @@ public class InputInvalidAnonymousClassIndent { //indent:0 exp:0 return new Thread(); //indent:20 exp:20 } else { //indent:16 exp:16 return new Thread(); //indent:20 exp:20 - }}}); //indent:16 ioffset:1 exp:12,16 warn + }}}); //indent:16 exp:16 return; //indent:8 exp:8 } //indent:4 exp:4 } //indent:0 exp:0 diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidForIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidForIndent.java index a8ef88bf6..4f7776c9a 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidForIndent.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidForIndent.java @@ -74,7 +74,7 @@ public class InputInvalidForIndent { //indent:0 exp:0 } //indent:8 exp:8 for (int i=0; i<10; i++) { //indent:8 exp:8 - System.getProperty("foo"); } //indent:12 ioffset:27 exp:8 warn + System.getProperty("foo"); } //indent:12 exp:12 for (int i=0; //indent:8 exp:8 i<10; i++ //indent:12 exp:>=12 diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidIfIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidIfIndent.java index b58081a60..f33f8a6d9 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidIfIndent.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputInvalidIfIndent.java @@ -230,7 +230,7 @@ System.getProperty("blah"); //indent:0 exp:12 warn } //indent:16 exp:16 if (test) { //indent:8 exp:8 - System.getProperty("blah"); } //indent:12 ioffset:28 exp:8 warn + System.getProperty("blah"); } //indent:12 exp:12 } //indent:4 exp:4 public void parenIfTest() { //indent:4 exp:4