-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ConflictDetection
utility class
#478
Conversation
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit with some suggestions.
Suggested commit message;
Introduce `ConflictDetection` utility class (#478)
import java.util.Optional; | ||
|
||
/** | ||
* A set of helper methods for finding conflicts which would be caused by applying certain fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not a huge fan of the "certain fixes".
I'm suggesting an alternative,feel free to revert or tweak :).
|
||
/** | ||
* A {@link BugChecker} that flags method rename blockers found by {@link | ||
* ConflictDetection#findMethodRenameBlocker(Symbol.MethodSymbol, String, VisitorState)}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* ConflictDetection#findMethodRenameBlocker(Symbol.MethodSymbol, String, VisitorState)}. | |
* ConflictDetection#findMethodRenameBlocker(MethodSymbol, String, VisitorState)}. |
@@ -8,8 +8,8 @@ | |||
import static com.google.errorprone.matchers.Matchers.hasModifier; | |||
import static com.google.errorprone.matchers.Matchers.not; | |||
import static java.util.function.Predicate.not; | |||
import static tech.picnic.errorprone.bugpatterns.util.ConflictDetection.findMethodRenameBlocker; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not statically import. That may read a bit better.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
1f246e1
to
85dba89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and added a commit. Didn't call out all changes.
void matcher() { | ||
CompilationTestHelper.newInstance(RenameBlockerFlagger.class, getClass()) | ||
.addSourceLines( | ||
"/A.java", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"/A.java", | |
"A.java", |
* <li>Whether the rename would merely introduce a method overload, rather than clashing with an | ||
* existing method declaration. | ||
* <li>Whether the rename would cause a method in a superclass to be overridden. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do check superclasses; let's rephrase this.
@Override | ||
public Description matchMethod(MethodTree tree, VisitorState state) { | ||
return ConflictDetection.findMethodRenameBlocker( | ||
ASTHelpers.getSymbol(tree), tree.getName() + "t", state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearer (or some variation hereof):
ASTHelpers.getSymbol(tree), tree.getName() + "t", state) | |
ASTHelpers.getSymbol(tree), tree.getName() + "WithSuffix", state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but then indeed the in
-> int
case is not tested nicely. Couldn't figure out a nicer way to do that. (Based on the changes not including this change I suspect you went through the same train of thoughts there 😉).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly 😄. Forgot to remove this comment 👍
import java.util.Optional; | ||
|
||
/** A set of helper methods for detecting conflicts that would be caused when applying fixes. */ | ||
public final class ConflictDetection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for now, but I suspect that eventually we'll want a more generic name. Time will tell :)
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
1 similar comment
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
I see that one mutant survived; will have a look at that in a bit. |
Looks good. All 20 mutations in this change were killed.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM!
@Override | ||
public Description matchMethod(MethodTree tree, VisitorState state) { | ||
return ConflictDetection.findMethodRenameBlocker( | ||
ASTHelpers.getSymbol(tree), tree.getName() + "t", state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but then indeed the in
-> int
case is not tested nicely. Couldn't figure out a nicer way to do that. (Based on the changes not including this change I suspect you went through the same train of thoughts there 😉).
by moving reusable conflict detection code from `JUnitMethodDeclaration` to a new `ConflictDetection` class.
0df7030
to
9dfb06b
Compare
Rebased, will merge once 🍏. |
Looks good. All 20 mutations in this change were killed.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
ConflictDetection
utility class
Suggested commit message: