-
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 ImmutableTableRules
Refaster rule collection
#1489
Conversation
Looks good. No mutations were possible for these changes. |
Looks good. All 1 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.
🪓
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.
Sorry, I wanted to add some comments; leaving approval otherwise 👍
@UseImportPolicy(STATIC_IMPORT_ALWAYS) | ||
ImmutableTable<R, C, V> after(Stream<E> stream) { | ||
return stream.collect( | ||
toImmutableTable(e -> rowFunction(e), e -> columnFunction(e), e -> valueFunction(e))); |
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.
Can't these can be lambda expressions?
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.
You mean method references? 🙃
Unfortunately, Refaster doesn't have a "make this a method reference if possible" feature.
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.
You mean method references? 🙃
Yes, sorry 🙈
private ImmutableTableRules() {} | ||
|
||
/** Prefer {@link ImmutableTable#builder()} over the associated constructor. */ | ||
// XXX: This rule may drop generic type information, leading to non-compilable code. |
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.
Technically it does not drop all generic type information, correct?
// XXX: This rule may drop generic type information, leading to non-compilable code. | |
// XXX: This rule may drop explicit generic type information, leading to non-compilable code. |
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.
Indeed, but it also says "may", so it's clear that anyway this is an issue only in a subset of cases. :)
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.
Tnx for the review @mohamedsamehsalah!
private ImmutableTableRules() {} | ||
|
||
/** Prefer {@link ImmutableTable#builder()} over the associated constructor. */ | ||
// XXX: This rule may drop generic type information, leading to non-compilable code. |
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.
Indeed, but it also says "may", so it's clear that anyway this is an issue only in a subset of cases. :)
@UseImportPolicy(STATIC_IMPORT_ALWAYS) | ||
ImmutableTable<R, C, V> after(Stream<E> stream) { | ||
return stream.collect( | ||
toImmutableTable(e -> rowFunction(e), e -> columnFunction(e), e -> valueFunction(e))); |
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.
You mean method references? 🙃
Unfortunately, Refaster doesn't have a "make this a method reference if possible" feature.
Validated that these changes do not impact the integration tests. |
} | ||
|
||
/** Prefer {@link ImmutableTable#of()} over more contrived alternatives . */ | ||
static final class ImmutableTableOf<R, C, V> { |
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.
Would it make sense to move this Refaster rule a bit more up? Like right after the builder or the ImmutableTableBuilderBuildOrThrow
one?
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 wondered the same, but modelled this after ImmutableMapRules
🤷. (If/when we decide to auto-sort rules, this kind of more semantic approach to ordering will likely go out the window. Something to consider.)
3e9746d
to
7d2a94d
Compare
Looks good. All 1 mutations in this change were killed.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
7d2a94d
to
58dcc7d
Compare
Quality Gate passedIssues Measures |
Looks good. All 1 mutations in this change were killed.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed. |
Suggested commit message:
This work results from #1223 and this comment, with the observation that
ImmutableTable
has a distinct builder type. The rules introduced here are a subset of those defined byImmutableMapRules
.