-
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
Improve JUnitMethodDeclaration
check
#406
Improve JUnitMethodDeclaration
check
#406
Conversation
There's no mutation testing report here, while #407, which I filed soon after this PR, has two (identical) reports for a single commit. I looked into the issue a bit and sent the following email to @hcoles of Arcmutate/CDG (in response to an earlier email in which Henry gave us a heads-up about this issue possibly existing):
|
33ac331
to
6f4a212
Compare
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
&& !isReservedKeyword(str) | ||
&& !BOOLEAN_AND_NULL_LITERALS.contains(str) | ||
&& Character.isJavaIdentifierStart(str.codePointAt(0)) | ||
&& str.codePoints().skip(1).allMatch(Character::isUnicodeIdentifierPart); |
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.
Pitest flags that mutants that remove .skip(1)
aren't killed. Without assuming that isUnicodeIdentifierPart
matches a superset of isJavaIdentifierStart
I can't drop this operation. But that assumption does hold in practice, IIUC, so writing a test for it is hard/impossible. There's also a (minute) performance aspect. TL;DR: I don't see how I can avoid this Pitest warning.
Implemented changes: - Ignore method overrides even if not annotated `@Override`. - Don't rename methods to `true`, `false` or `null`. - Don't rename methods to a name declared in a super type. This prevents e.g. renaming `testToString` to `toString`.
6f4a212
to
7fa268f
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.
Some minor comments with questions mostly :).
Changes LGTM!
Made one tweak to suggested commit message.
|
||
final class JavaKeywordsTest { | ||
private static Stream<Arguments> isValidIdentifierTestCases() { | ||
return Stream.of( |
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.
return Stream.of( | |
/* { str, expected } */ | |
return Stream.of( |
Matchers.not(hasModifier(Modifier.FINAL)), | ||
Matchers.not(hasModifier(Modifier.PRIVATE)), | ||
enclosingClass(hasModifier(Modifier.ABSTRACT)))); | ||
Sets.immutableEnumSet(Modifier.PRIVATE, Modifier.PROTECTED, Modifier.PUBLIC); |
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.
What is the reason for this change? :)
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.
More efficient storage and retrieval, just like what we do here.
} | ||
|
||
return Optional.empty(); | ||
} | ||
|
||
private static boolean isExistingMethodName(Type clazz, String name, VisitorState state) { | ||
return ASTHelpers.matchingMethods(state.getName(name), x -> true, clazz, state.getTypes()) |
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 could signal that it's unused by naming x
unused
. Not sure if we gain a lot there though.
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, the scope is very small, so it's clear that the parameter is unused. Perhaps better would be s/x/method/
, since it's a predicate over methods.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Hmm, I think it reads better without the word "with". Just like something "is annotated (Need to leave train; will check rest later.) |
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. Tnx for the reviews!
W.r.t. the commit message: can live with it, so merge as you see fit.
Matchers.not(hasModifier(Modifier.FINAL)), | ||
Matchers.not(hasModifier(Modifier.PRIVATE)), | ||
enclosingClass(hasModifier(Modifier.ABSTRACT)))); | ||
Sets.immutableEnumSet(Modifier.PRIVATE, Modifier.PROTECTED, Modifier.PUBLIC); |
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.
More efficient storage and retrieval, just like what we do here.
} | ||
|
||
return Optional.empty(); | ||
} | ||
|
||
private static boolean isExistingMethodName(Type clazz, String name, VisitorState state) { | ||
return ASTHelpers.matchingMethods(state.getName(name), x -> true, clazz, state.getTypes()) |
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, the scope is very small, so it's clear that the parameter is unused. Perhaps better would be s/x/method/
, since it's a predicate over methods.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Resolves issues found while testing Error Prone Support against Checkstyle (currently testing on this branch).
Suggested commit message: