-
Notifications
You must be signed in to change notification settings - Fork 38.9k
[prone] Add TimeRulesRecipes
#35861
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?
[prone] Add TimeRulesRecipes
#35861
Conversation
| - tech.picnic.errorprone.refasterrules.StreamRulesRecipes | ||
| # TBD | ||
| # - org.openrewrite.java.migrate.Java8toJava11 # https://github.com/google/error-prone/pull/5328 | ||
| # - org.openrewrite.java.migrate.UpgradeToJava17 # https://github.com/checkstyle/checkstyle/pull/17730 |
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.
Since Checkstyle is already used within Spring, it’s effectively part of the project transitively.
Integrating these rules directly could improve a lot of code and allow best practices to be applied effortlessly and consistently.
| version=$(sed -n 's/version=\(.*\)/\1/p' gradle.properties) | ||
| echo "Version is $version" | ||
| echo "version=$version" >> $GITHUB_OUTPUT | ||
| - name: SanityCheck |
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’m not sure if this is the right place to check. Having this last in place should allow most of the other steps to work, but it still ends up failing with a corrupt version.
| import java.util.Set; | ||
| import java.util.stream.StreamSupport; | ||
|
|
||
| import com.google.common.collect.Streams; |
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.
Apart from the commons-logging and micrometer-api dependencies there are no 3rd party dependencies in Spring. I doubt adding a dependency on Google Guava is going to happen anytime soon.
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.
yes this seems questionable. Thanks for the hint.
|
|
||
| List<Element> subList = elements.subList(fromIndex, toIndex); | ||
| String path = subList.stream().map(Element::value).collect(Collectors.joining("")); | ||
| String path = subList.stream().map(Element::value).collect(joining()); |
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 believe there is a no static import rule.
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.
yes it seems to be the bulky and verbose checkstyle style and not the slim google approach.
mdeinum
left a comment
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.
Looking at existing rules and deliberate care in dependencies I would expect some changes. Which would mean that the rewrite rules aren't applicable.
StreamRulesRecipesTimeRulesRecipes
Signed-off-by: Vincent Potucek <vpotucek@me.com>
a8e5b97 to
def2188
Compare
Thank you for the kind feedback. I’ve reworked the scope to focus on the TimeRules. Hopefully this is something easier to consider.
I think it’s difficult to judge something universally or generically; each scope has its own individual context. This is the first project that passed the included GradleBestPractices checks without any findings. Considering the Java8toJava11 migration, as explored in
the code compiles on Java 21+ while still largely using Java 8–era and Java 17–era constructs. |
spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java
Show resolved
Hide resolved
spring-test/src/test/java/org/springframework/test/web/servlet/client/RestTestClientTests.java
Show resolved
Hide resolved
| @Test | ||
| void resolveCustomizedAndTimeZoneLocale() { | ||
| TimeZone timeZone = TimeZone.getTimeZone(ZoneId.of("UTC")); | ||
| TimeZone timeZone = TimeZone.getTimeZone(ZoneOffset.UTC); |
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 seems a good thing to consider, being straight up instead of "error prone".
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.
What do you mean?
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 meant this is a good thing and seems easy consider suggest, as it avoids error prone (random) string.
Congratulations on the recent major release — a lot of work has clearly gone into it.
I'm sure Spring Boot will continue to succeed as well.
I’d kindly like to suggest considering Error Prone integration featuring the TimeRules findings:
As discussed in:
rewritesupport forerrorprone.refasterrules#35270