-
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 HasTypeArguments
matcher
#644
Conversation
error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/MoreMatchers.java
Outdated
Show resolved
Hide resolved
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. |
MoreMatchers#hasTypeArguments()
matcherHasTypeArguments
matcher
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Looks good. All 12 mutations in this change were killed.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
"", | ||
" Foo positive3() {", | ||
" // BUG: Diagnostic contains:", | ||
" return new <List<Object>>Foo(List.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.
There's is probably a better example of this
1655979
to
d0452ab
Compare
Looks good. All 12 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.
Added a small commit. Not done reviewing yet but wanted to flush what I have 😄.
refaster-support/src/main/java/tech/picnic/errorprone/refaster/matchers/HasTypeArguments.java
Outdated
Show resolved
Hide resolved
return false; | ||
} | ||
|
||
return !((ParameterizedTypeTree) classTree.getIdentifier()).getTypeArguments().isEmpty(); |
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 can extract classTree.getIdentifier()
as we use it twice.
"", | ||
"class A {", | ||
" Object negative1() {", | ||
" return alwaysNull();", |
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 can simply use toString()
here :)
"", | ||
" <E> ImmutableSet<E> positive1() {", | ||
" // BUG: Diagnostic contains:", | ||
" return ImmutableSet.<E>builder().build();", |
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 can probably simplify by:
" List<Integer> positive1() {",
" return new ArrayList<Integer>();",
" }",
"",
(Will apply this tomorrow when I get back to this.
Kudos, SonarCloud Quality Gate passed! |
Looks good. All 12 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.
I like the idea behind this new Matcher
, but I wonder how it's meant to be used in #46, because the Refaster template methods modified in that PR don't accept any parameters: the new X()
/ new X<...>()
constructor invocations against which we want to match are explicitly defined in the method bodies, so there's no place to put the @Matches
/@NotMatches
annotations? 🤔
That is something I ran into as well, but haven't had a super good look into it. |
I think we can close this PR, as the main goal of this |
Introduces a
Matcher
that matches{MethodInvocation,NewClass}Tree
instances declared with type arguments.Should unblock #46