From 11eb99681a05047aecc2ce4b4bc51c849d1cfd44 Mon Sep 17 00:00:00 2001 From: Baratali Izmailov Date: Sun, 30 Aug 2015 07:48:19 -0400 Subject: [PATCH] Issue #1566: Fixed CyclomaticComplexity violations in IndentationCheckTest --- .../checks/indentation/IndentationCheckTest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 12ae2c789..b51ad5836 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 @@ -144,9 +144,7 @@ public class IndentationCheckTest extends BaseCheckTestSupport { Matcher singleLevelMatch = SINGLELEVEL_COMMENT_REGEX.matcher(comment); if (singleLevelMatch.matches()) { final int expectedLevel = Integer.parseInt(singleLevelMatch.group(1)); - - return expectedLevel == indentInComment && !isWarnComment - || expectedLevel != indentInComment && isWarnComment; + return isSingleLevelCommentConsistent(indentInComment, isWarnComment, expectedLevel); } Matcher nonStrictLevelMatch = NONSTRICT_LEVEL_COMMENT_REGEX.matcher(comment); @@ -160,6 +158,12 @@ public class IndentationCheckTest extends BaseCheckTestSupport { throw new IllegalStateException("Comments are not consistent"); } + private static boolean isSingleLevelCommentConsistent(int indentInComment, boolean isWarnComment, + int expectedLevel) { + return expectedLevel == indentInComment && !isWarnComment + || expectedLevel != indentInComment && isWarnComment; + } + private static int getLineStart(String line, final int tabWidth) { for (int index = 0; index < line.length(); ++index) { if (!Character.isWhitespace(line.charAt(index))) {