-
Notifications
You must be signed in to change notification settings - Fork 46
Introduce SetStream
Refaster rule
#1264
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
Conversation
Looks good. No mutations were possible for these changes. |
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.
Suggested commit message:
Introduce `SetStream` Refaster rule (#1264)
} | ||
} | ||
|
||
/** Rely on Set's property to preserve distinct elements. */ |
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.
This does assume that the set doesn't use a custom equality, like a SortedSet
might. Will add a note:
/** Rely on Set's property to preserve distinct elements. */ | |
/** Don't unnecessarily call {@link Stream#distinct()} on an already-unique stream of elements. */ | |
// XXX: This rule assumes that the `Set` relies on `Object#equals`, rather than a custom | |
// equivalence relation. | |
// XXX: Expressions that drop or reorder elements from the stream, such as `.filter`, `.skip` and | |
// `sorted`, can similarly be simplified. Covering all cases is better done using an Error Prone | |
// check. |
(I'm not too worried about false positives: it's likely rare that there is code that wants cares about both types of deduplication in a single context.)
SetStream
Refaster rule
Looks good. No mutations were possible for these changes. |
|
||
/** Rely on Set's property to preserve distinct elements. */ | ||
/** Don't unnecessarily call {@link Stream#distinct()} on an already-unique stream of elements. */ | ||
// XXX: This rule assumes that the `Set` relies on `Object#equals`, rather than a custom |
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.
🧠
e8e702c
to
e04b23c
Compare
Looks good. No mutations were possible for these changes. |
@hpnog Any additions from your side :)? |
e04b23c
to
a00559f
Compare
Looks good. No mutations were possible for these changes. |
|
I think this is a candidate for "combinations of operators that don't make sense".
I tried to extend the rule with rules like
But the number of permutations of different operators before using
#distinct
is a lot.Suggested commit message