Skip to content

Commit

Permalink
fixup! Merge fixes of inner type decls, enable sorting nested types i…
Browse files Browse the repository at this point in the history
…n one-go
  • Loading branch information
benhalasi committed Dec 7, 2024
1 parent 47e27eb commit 0bc5f94
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,7 @@ public Description matchCompilationUnit(
return describeMatch(compilationUnitTree, suggestedFix);
}

/**
* Matches a class.
*
* @param tree xxx
* @param state xxx
* @param compilationUnit xxx
* @return xxx
*/
public SuggestedFix matchClass(
private SuggestedFix matchClass(
ClassTree tree, VisitorState state, JCTree.JCCompilationUnit compilationUnit) {
Kind treeKind = tree.getKind();
if (treeKind != Kind.CLASS && treeKind != Kind.INTERFACE && treeKind != Kind.ENUM) {

Check warning on line 95 in error-prone-experimental/src/main/java/tech/picnic/errorprone/experimental/bugpatterns/TypeMemberOrder.java

View workflow job for this annotation

GitHub Actions / pitest

3 different changes can be made to line 95 without causing a test to fail

removed conditional - replaced equality check with false (covered by 18 tests RemoveConditionalMutator_EQUAL_ELSE) removed conditional - replaced equality check with false (covered by 12 tests RemoveConditionalMutator_EQUAL_ELSE) removed conditional - replaced equality check with false (covered by 10 tests RemoveConditionalMutator_EQUAL_ELSE)
Expand Down Expand Up @@ -267,9 +259,7 @@ private static SuggestedFix sortTypeMembers(
return original.equals(replacement)

Check warning on line 259 in error-prone-experimental/src/main/java/tech/picnic/errorprone/experimental/bugpatterns/TypeMemberOrder.java

View workflow job for this annotation

GitHub Actions / pitest

A change can be made to a lambda on line 259 without causing a test to fail

removed conditional - replaced equality check with false in 1st lambda in sortTypeMembers (covered by 18 tests RemoveConditionalMutator_EQUAL_ELSE)
? SuggestedFix.emptyFix()
: SuggestedFix.replace(
original.startPosition(),
original.endPosition(),
replacementSource.toString());
original.startPosition(), original.endPosition(), replacementSource);
})
.reduce(SuggestedFix.builder(), SuggestedFix.Builder::merge, SuggestedFix.Builder::merge)
.build();
Expand All @@ -296,11 +286,11 @@ abstract static class TypeMember implements Comparable<TypeMember> {

abstract int endPosition();

abstract Integer preferredOrdinal();
abstract int preferredOrdinal();

@Override
public int compareTo(TypeMemberOrder.TypeMember o) {
return preferredOrdinal().compareTo(o.preferredOrdinal());
return Integer.compare(preferredOrdinal(), o.preferredOrdinal());
}
}
}

0 comments on commit 0bc5f94

Please sign in to comment.