-
Notifications
You must be signed in to change notification settings - Fork 96
feat: add recipe that prefers guava ranges #787
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
base: main
Are you sure you want to change the base?
Conversation
src/main/java/org/openrewrite/java/migrate/guava/UseRanges.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/guava/UseRanges.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/guava/UseRanges.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/guava/UseRanges.java
Outdated
Show resolved
Hide resolved
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.
Perfect use case for Refaster here @timo-a ; thanks a lot for adding these. Did you already try them out in detail on your projects?
I'll need to take a closer look still at the various open/closed vs <=
operators used, but should be fairly straightforward to compare and get merged after that.
I have not tried them out in any project! Take your time to review, there is no rush 😄 One more thing, can these be published under Apache 2? I believe the community involvement here is significant, so that should work according to the license page. As that page now explicitly forbids consultants to use MSAL recipes, I want to ensure my colleagues and I can use those recipes at work. (I have already published them in my own repo under apache 2 but it would be nice to have them in the official catalogue) |
Hi @timo-a ; while I'm certainly sympathetic to your request, for now we lack an ability to license individual recipes separately. We apply recipes per module, and apply those licenses through a mixture of build tool plugins to update headers, META-INF and pom.xml So while we'd love to adopt your recipes and distribute those to the wider community, we can not make individual exceptions here unfortunately. Up to you then if you'd still like to contribute these for the wider community to consume, where we take on a role to polish, release and maintain these going forward. And of course you can still separately keep your own internal copies in parallel as well. |
What's changed?
adds recipe that converts
from.compareTo(candidate) <= 0 && candidate.compareTo(to) <= 0
into more idiomatic guava ranges.Covers opened, closed and half-open intervals of
Comparable
s and primitives.What's your motivation?
Make code more readable
Anything in particular you'd like reviewers to focus on?
candidate
as a name for the object that is tested for its membership. Maybe there is a better name.from <= candidate && candidate <= to
is fairly easy to read. For uniformity, I chose to have it converted toRange.closed(from, to).contains(candidate)
anyway.Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Checklist