-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| apply plugin: 'org.openrewrite.rewrite' | ||
|
|
||
| rewrite { | ||
| activeRecipe('org.springframework.openrewrite.SanityCheck') | ||
| setExportDatatables(true) | ||
| setFailOnDryRunResults(true) | ||
| } | ||
|
|
||
| dependencies { | ||
| rewrite(platform('org.openrewrite.recipe:rewrite-recipe-bom:3.18.0')) | ||
| rewrite('org.openrewrite.recipe:rewrite-rewrite:0.15.0') | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| type: specs.openrewrite.org/v1beta/recipe | ||
| name: org.springframework.openrewrite.SanityCheck | ||
| displayName: Apply all Java & Gradle best practices | ||
| description: Comprehensive code quality recipe combining modernization, security, and best practices. | ||
| tags: | ||
| - java | ||
| - gradle | ||
| - static-analysis | ||
| - cleanup | ||
| recipeList: | ||
| - org.openrewrite.gradle.EnableGradleBuildCache | ||
| - org.openrewrite.gradle.EnableGradleParallelExecution | ||
| - org.openrewrite.gradle.GradleBestPractices | ||
| - tech.picnic.errorprone.refasterrules.TimeRulesRecipes | ||
| # 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 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| --- | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
|
|
||
| package org.springframework.web.server.i18n; | ||
|
|
||
| import java.time.ZoneId; | ||
| import java.time.ZoneOffset; | ||
| import java.util.Locale; | ||
| import java.util.TimeZone; | ||
|
|
||
|
|
@@ -61,7 +61,7 @@ void resolveCustomizedLocale() { | |
|
|
||
| @Test | ||
| void resolveCustomizedAndTimeZoneLocale() { | ||
| TimeZone timeZone = TimeZone.getTimeZone(ZoneId.of("UTC")); | ||
| TimeZone timeZone = TimeZone.getTimeZone(ZoneOffset.UTC); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| FixedLocaleContextResolver resolver = new FixedLocaleContextResolver(FRANCE, timeZone); | ||
| TimeZoneAwareLocaleContext context = (TimeZoneAwareLocaleContext) resolver.resolveLocaleContext(exchange()); | ||
| assertThat(context.getLocale()).isEqualTo(FRANCE); | ||
|
|
||
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.