Skip to content

Commit

Permalink
Fix quality flaw: fix number of nested if
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohops committed Oct 4, 2016
1 parent 263e7a3 commit ef4579d
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,26 @@ public List<Tree.Kind> nodesToVisit() {
@Override
public void visitNode(Tree tree) {
ClassTree classTree = (ClassTree) tree;
if (isComparable(classTree)) {
boolean hasEquals = false;
MethodTree compare = null;
if (!isComparable(classTree)) {
return;
}
boolean hasEquals = false;
MethodTree compare = null;

for (Tree member : classTree.members()) {
if (member.is(Tree.Kind.METHOD)) {
MethodTree method = (MethodTree) member;
for (Tree member : classTree.members()) {
if (member.is(Tree.Kind.METHOD)) {
MethodTree method = (MethodTree) member;

if (isEqualsMethod(method)) {
hasEquals = true;
} else if (isCompareToMethod(method)) {
compare = method;
}
if (isEqualsMethod(method)) {
hasEquals = true;
} else if (isCompareToMethod(method)) {
compare = method;
}
}
}

if (compare != null && !hasEquals) {
reportIssue(compare.simpleName(), "Override \"equals(Object obj)\" to comply with the contract of the \"compareTo(T o)\" method.");
}
if (compare != null && !hasEquals) {
reportIssue(compare.simpleName(), "Override \"equals(Object obj)\" to comply with the contract of the \"compareTo(T o)\" method.");
}
}

Expand Down

0 comments on commit ef4579d

Please sign in to comment.