-
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 assorted Optional
Refaster rules
#764
Conversation
Looks good. No mutations were possible for these changes. |
19a14c3
to
28f250c
Compare
Looks good. No mutations were possible for these changes. |
28f250c
to
b6d33e6
Compare
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 with small suggestions. Otherwise LGTM so already approving.
@@ -100,6 +100,20 @@ Function<Optional<T>, T> after() { | |||
} | |||
} | |||
|
|||
/** Prefer {@link Optional#equals(Object)} over more contrived alternatives. */ | |||
static final class OptionalHasValue<T, S> { |
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, I'm not sure if I agree with the name based on our naming algorithm 🤔.
OptionalEquals
or OptionalEqualsOptional
seems more accurate, WDYT?
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 guess even OptionalEqualsOptionalOf
; but this work for me for now 👍
return optional.stream(); | ||
} | ||
} | ||
|
||
// XXX: Add a rule for: | ||
// `optional.flatMap(x -> pred(x) ? Optional.empty() : Optional.of(x))` and variants. | ||
// (Maybe canonicalize the inner expression. Maybe we rewrite already.) |
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.
// (Maybe canonicalize the inner expression. Maybe we rewrite already.) | |
// (Maybe canonicalize the inner expression. Maybe we rewrite it already.) |
A tiny improvement IMO.
Looks good. No mutations were possible for these changes. |
f88cf68
to
35e7fe5
Compare
Looks good. No mutations were possible for these changes. |
While there, move the `OptionalOrElseGet` Refaster rule test code to its properly location.
35e7fe5
to
18ecbb8
Compare
Looks good. No mutations were possible for these changes. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Suggested commit message: