RightCurlyCheck updated to follow Cyclomatic Complexity rule. #954
This commit is contained in:
parent
ae0e7def77
commit
c99f34002b
|
|
@ -22,7 +22,10 @@
|
|||
<properties>
|
||||
<property name="showClassesComplexity" value="false"/>
|
||||
<property name="reportLevel" value="11"/>
|
||||
<property name="violationSuppressXPath" value="//MethodDeclaration[@Name='validateCli' and ../../..[@Image='Main']]"/>
|
||||
<!-- validateCli is not reasonbale to split as incapsulation of logic will be damaged
|
||||
getDetails - huge Switch, it has to be monolitic
|
||||
-->
|
||||
<property name="violationSuppressXPath" value="//MethodDeclaration[@Name='validateCli' and ../../..[@Image='Main']] | //MethodDeclaration[@Name='getDetails' and ../../..[@Image='RightCurlyCheck']]"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/codesize.xml/TooManyMethods">
|
||||
|
|
|
|||
|
|
@ -154,6 +154,28 @@ public class RightCurlyCheck extends AbstractOptionCheck<RightCurlyOption> {
|
|||
}
|
||||
|
||||
final DetailAST lcurly = details.lcurly;
|
||||
|
||||
validate(details, rcurly, lcurly);
|
||||
|
||||
if (!shouldStartLine) {
|
||||
return;
|
||||
}
|
||||
final boolean startsLine =
|
||||
Utils.whitespaceBefore(rcurly.getColumnNo(),
|
||||
getLines()[rcurly.getLineNo() - 1]);
|
||||
|
||||
if (!startsLine && lcurly.getLineNo() != rcurly.getLineNo()) {
|
||||
log(rcurly, MSG_KEY_LINE_NEW, "}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* do general validation
|
||||
* @param details details
|
||||
* @param rcurly right curly token
|
||||
* @param lcurly left curly token
|
||||
*/
|
||||
private void validate(Details details, DetailAST rcurly, DetailAST lcurly) {
|
||||
final DetailAST nextToken = details.nextToken;
|
||||
final boolean shouldCheckLastRcurly = details.shouldCheckLastRcurly;
|
||||
|
||||
|
|
@ -175,17 +197,6 @@ public class RightCurlyCheck extends AbstractOptionCheck<RightCurlyOption> {
|
|||
&& !isEmptyBody(lcurly)) {
|
||||
log(rcurly, MSG_KEY_LINE_ALONE, "}");
|
||||
}
|
||||
|
||||
if (!shouldStartLine) {
|
||||
return;
|
||||
}
|
||||
final boolean startsLine =
|
||||
Utils.whitespaceBefore(rcurly.getColumnNo(),
|
||||
getLines()[rcurly.getLineNo() - 1]);
|
||||
|
||||
if (!startsLine && lcurly.getLineNo() != rcurly.getLineNo()) {
|
||||
log(rcurly, MSG_KEY_LINE_NEW, "}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue