Skip to content

Commit

Permalink
Issue checkstyle#3685: Extracted logic to function
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarshah94 committed Mar 2, 2017
1 parent 75c6045 commit b89c489
Showing 1 changed file with 15 additions and 8 deletions.
Expand Up @@ -175,20 +175,27 @@ public void visitToken(DetailAST ast) {

if (rcurly != null) {
final String violation;
final String targetSourceLine;
if (shouldStartLine) {
targetSourceLine = getLines()[rcurly.getLineNo() - 1];
}
else {
targetSourceLine = "";
}
violation = validate(details, option, shouldStartLine, targetSourceLine);
violation = validate(details, option, shouldStartLine, getTargetSourceLine(rcurly.getLineNo()-1));
if (!violation.isEmpty()) {
log(rcurly, violation, "}", rcurly.getColumnNo() + 1);
}
}
}

/**
*
* @param lineNo for fetching lines
* @return lines associated with line no
*/
private String getTargetSourceLine(int lineNo) {
if (shouldStartLine) {
return getLines()[lineNo];
}
else {
return "";
}
}

/**
* Does general validation.
* @param details for validation.
Expand Down

0 comments on commit b89c489

Please sign in to comment.