-
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
Extend TimeRules
Refaster rule collection
#979
Conversation
plus###
and minus###
shorthands when possible for dates/times
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.
When you asked me offline whether we could do this better, I didn't expect there to be this many cases, haha. Perhaps an Error Prone check would make sense, but it might be nice to get this merged first. (There are also other Refaster rules that may benefit from generalization.)
@@ -582,4 +582,980 @@ Period after() { | |||
return Period.ZERO; | |||
} | |||
} | |||
|
|||
/** Prefer {@link LocalDate#plusDays} (and variants) over more contrived alternatives. */ |
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 couldn't help my self and applied it to all rules; will push 😅
@BeforeTemplate | ||
LocalDate before(LocalDate localDate, int days) { | ||
return Refaster.anyOf( | ||
localDate.plus(days, ChronoUnit.DAYS), localDate.plus(Period.ofDays(days))); | ||
} |
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.
By matching against int
here (for compatibility with the second case) we're not matching the first case for long
parameters (LocalDate.EPOCH.plus(1L, ChronoUnit.DAYS)
isn't matched).
Let me see whether I can regex a fix for this 😅
Looks good. No mutations were possible for these changes. |
2 similar comments
Looks good. No mutations were possible for these changes. |
Looks good. No mutations were possible for these changes. |
Added two commits. Suggested commit message:
|
Thanks @Stephan202! 🦸🏻♂️ |
20105c8
to
42acc34
Compare
Looks good. No mutations were possible for these changes. |
1 similar comment
Looks good. No mutations were possible for these changes. |
42acc34
to
e527dba
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.
Used my brain to do a lot of pattern matching during the review 🧠 .
Nice work guys 😄.
Looks good. No mutations were possible for these changes. |
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 1 New issue |
Nice suggested commit message @Stephan202 ! |
plus###
and minus###
shorthands when possible for dates/timesTimeRules
Refaster rule collection
Uses e.g.
LocalDate#plusDays
instead of more contrived alternatives.Quite a big PR as sadly none of the involved classes share a common interface for the shorthand methods.