Issue #1566: Fixed CyclomaticComplexity violations in IndentationCheckTest

This commit is contained in:
Baratali Izmailov 2015-08-30 07:48:19 -04:00 committed by Roman Ivanov
parent 9c21acf16a
commit 11eb99681a
1 changed files with 7 additions and 3 deletions

View File

@ -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))) {