Skip to content

Conversation

@Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Jan 4, 2026

Inspired by the change initiated in #48630, this appears to be the matching counterpart to the StaticImports rule.

Although the rule is active and covered by tests (the emptyList example works as expected), it is currently not functioning as intended. This should therefore be filed as a simple bug report in the Rewrite repository and fixed afterward.

Despite this, we could also apply the same changes and alignments here, similar to what was done in the framework.

As in the framework, this change involves the same file- and time-based updates and could be aligned accordingly:

Referes to:

Changes:

Changes have been made to build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ClassPath.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$PathOfUriRecipe
Changes have been made to buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$FilesCreateTempFileToFileRecipe
Changes have been made to buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Cache.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityRecipe
Changes have been made to buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildpackReference.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$PathOfUriRecipe
Changes have been made to buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerConfigurationMetadataTests.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$PathOfUriRecipe
Changes have been made to buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/configuration/ResolvedDockerHostTests.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$PathOfUriRecipe
Changes have been made to buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilderTests.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$UtcConstantRecipe
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$InstantAtOffsetRecipe
Changes have been made to buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildRequestTests.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$UtcConstantRecipe
Changes have been made to buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/ImageBuildpackTests.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$FilesCreateTempFileToFileRecipe
Changes have been made to cli/spring-boot-cli/src/test/resources/commands/command.groovy by:
    org.openrewrite.java.format.RemoveTrailingWhitespace
Changes have been made to cli/spring-boot-cli/src/test/resources/dir-sample/code/app.groovy by:
    org.openrewrite.java.format.RemoveTrailingWhitespace
Changes have been made to cli/spring-boot-cli/src/test/resources/scripts/closure.groovy by:
    org.openrewrite.java.format.RemoveTrailingWhitespace
Changes have been made to cli/spring-boot-cli/src/test/resources/scripts/command.groovy by:
    org.openrewrite.java.format.RemoveTrailingWhitespace
Changes have been made to core/spring-boot/src/test/java/org/springframework/boot/info/SslInfoTests.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$UtcConstantRecipe
Changes have been made to core/spring-boot/src/test/java/org/springframework/boot/logging/AbstractLoggingSystemTests.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$FilesCreateTempFileToFileRecipe
Changes have been made to core/spring-boot/src/test/java/org/springframework/boot/convert/PeriodToStringConverterTests.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$ZeroPeriodRecipe
Changes have been made to core/spring-boot/src/test/java/org/springframework/boot/convert/PeriodStyleTests.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$ZeroPeriodRecipe
Changes have been made to core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityRecipe
Changes have been made to core/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityLambdaRecipe
Changes have been made to loader/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/protocol/nested/NestedUrlConnection.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$UtcConstantRecipe
Changes have been made to loader/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/SizeCalculatingEntryWriter.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$FilesCreateTempFileToFileRecipe
Changes have been made to module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/exchanges/HttpExchange.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$ClockInstantRecipe
Changes have been made to module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$FilesCreateTempFileToFileRecipe
Changes have been made to module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoPropertiesInfoContributor.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityRecipe
Changes have been made to module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityRecipe
Changes have been made to module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityRecipe
Changes have been made to module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/MainMethodTests.java by:
    org.openrewrite.staticanalysis.ReplaceLambdaWithMethodReference
Changes have been made to module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyWebServerFactoryCustomizer.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityRecipe
Changes have been made to module/spring-boot-jetty/src/test/java/org/springframework/boot/jetty/autoconfigure/JettyWebServerFactoryCustomizerTests.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$FilesCreateTempFileToFileRecipe
Changes have been made to module/spring-boot-kafka/src/main/java/org/springframework/boot/kafka/autoconfigure/ConcurrentKafkaListenerContainerFactoryConfigurer.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityRecipe
Changes have been made to module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/ssl/SslMeterBinder.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$ClockInstantRecipe
Changes have been made to module/spring-boot-micrometer-metrics/src/test/java/org/springframework/boot/micrometer/metrics/autoconfigure/ssl/SslMeterBinderTests.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$UtcConstantRecipe
Changes have been made to module/spring-boot-security/src/test/java/org/springframework/boot/security/autoconfigure/UserDetailsServiceAutoConfigurationTests.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityLambdaRecipe
Changes have been made to module/spring-boot-sql/src/main/java/org/springframework/boot/sql/autoconfigure/init/OnDatabaseInitializationCondition.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityRecipe
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$NegationRecipe
Changes have been made to module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/servlet/TomcatServletWebServerFactoryTests.java by:
    org.openrewrite.staticanalysis.ReplaceLambdaWithMethodReference
Changes have been made to module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/observation/autoconfigure/WebFluxObservationAutoConfigurationTests.java by:
    tech.picnic.errorprone.refasterrules.TimeRulesRecipes
        tech.picnic.errorprone.refasterrules.TimeRulesRecipes$DurationOfSecondsRecipe
Changes have been made to module/spring-boot-zipkin/src/main/java/org/springframework/boot/zipkin/autoconfigure/ZipkinHttpClientSender.java by:
    org.openrewrite.staticanalysis.ReplaceLambdaWithMethodReference
Changes have been made to test-support/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/Resources.java by:
    tech.picnic.errorprone.refasterrules.FileRulesRecipes
        tech.picnic.errorprone.refasterrules.FileRulesRecipes$PathOfUriRecipe
Changes have been made to test-support/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/system/OutputCapture.java by:
    tech.picnic.errorprone.refasterrules.EqualityRulesRecipes
        tech.picnic.errorprone.refasterrules.EqualityRulesRecipes$EnumReferenceEqualityLambdaRecipe
Please review and commit the results.
Estimate time saved: 3h 6m

BUILD SUCCESSFUL in 18m 9s

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 4, 2026
@wilkinsona
Copy link
Member

Thanks for the proposal. There's some overlap with what's already covered by Spring Java Format and its Checkstyle rules. I'd like to discuss this with the team as that duplication doesn't feel great. We may want to take a similar approach to the Framework team where they applied (some of) the code changes without introducing the new tooling infrastructure.

@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Jan 5, 2026
@Pankraz76
Copy link
Author

Pankraz76 commented Jan 5, 2026

already covered

Yes, more or less all tools try to solve the same issue. Still, it’s just software, which means it’s full of bugs and flaws—like everything else we are used to.
In the end, every tool has blind spots, which makes it worthwhile to interconnect them and genuinely try to cover the issue, rather than just pretending to do so by using some tool here and there.

For whitespace checks, Checkstyle has an estimated ~90% error rate for whitespace-related issues and remains quite blind because it is not type-aware. PMD, Rewrite, and Error Prone address this problem, which makes them strong candidates for layering. No single tool is capable of catching everything on its own.


We may want to take a similar approach to the Framework team where they [applied (some of) the code changes](spring-projects/spring-framework#35861 (comment)) without introducing the new tooling infrastructure.

Of course, it’s nice to have the issues actually fixed. Still, this approach isn’t ideal—it addresses the symptoms rather than the root cause. As a result, the effort is somewhat wasted, because the problem is never truly done, only temporarily mitigated.

In the end, only automation can scale properly. That’s why automation is the correct approach to solve this issue once and properly, instead of fixing it once while still allowing the same flaws and issues to reoccur later. Otherwise, the entire effort and initiative become questionable if they are not done in a sustainable way.


I understand that it’s not pleasant to introduce a new tool, as humans tend to struggle with adapting to new standards. Nevertheless, that is ultimately what life is about: adaptation. For those who don’t adapt, nature itself has a clear and direct response.

From my perspective, there are only two options. The first is to adapt to the new reality and incorporate the tool, using it to fix flaws systematically instead of repeatedly patching symptoms. The second is to continue with the current approach, which leaves doors wide open for flaws, issues, and potentially even bugs that could otherwise be addressed by this kind of tooling—especially considering null-related recipes designed to prevent NPEs upfront.


Thanks for the attention given.

@Pankraz76
Copy link
Author

Pankraz76 commented Jan 5, 2026

duplication doesn't feel great

In this case, it's called redundancy—imposing a common principle for critical infrastructure.
It’s kind of the same reason why you have Checkstyle on Checkstyle, so I don’t see any problem with this argument.
It’s actually a feature, not a bug ;-)

@Pankraz76 Pankraz76 force-pushed the fix-EqualityRulesRecipes-pr branch from 1a3ce30 to 0417e12 Compare January 5, 2026 13:41
@Pankraz76 Pankraz76 changed the title Add SanityCheck#EqualityRulesRecipes #48630 Add UseStaticImport #48630 Jan 5, 2026
Signed-off-by: Vincent Potucek <[email protected]>
@Pankraz76 Pankraz76 force-pushed the fix-EqualityRulesRecipes-pr branch from 0417e12 to da8537f Compare January 5, 2026 15:27
displayName: Use static import
recipeList:
- org.openrewrite.java.UseStaticImport:
methodPattern: org.assertj.core.api.Assertions *(..)
Copy link
Author

@Pankraz76 Pankraz76 Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so its actually not working as expected. Might be an bug or wrong regex.

Kindly asking @timtebeek how to solve this, please?

@Pankraz76
Copy link
Author

Updated PR accordingly to just match the java.util.Collections emptySet() as tryout and foundation. Investigation further why the actual import is not applied as desired.

@wilkinsona
Copy link
Member

We discussed this today and decided that we don't want to adopt any additional static analysis tools at this time. We're happy with our current approach using Checkstyle and ArchUnit. Thanks anyway for the PR.

@wilkinsona wilkinsona closed this Jan 5, 2026
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Jan 5, 2026
@philwebb philwebb changed the title Add UseStaticImport #48630 Add UseStaticImport Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants