openrewrite / openrewrite/rewrite
Why doesn't OpenRewrite fully migrate my code?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
https://docs.openrewrite.org/reference/faq#why-doesnt-openrewrite-fully-migrate-my-code
I often notice that the recipes don't migrate completely. However, I don't see a consistent pattern.
Could it be that modified classes in subsequent recipes are being ignored?
Are there any specific orders that need to be followed (documentation)?
Here is my Maven POM:
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.37.0</version>
<executions>
<execution>
<id>run-rewrite</id>
<phase>process-sources</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<exportDatatables>false</exportDatatables>
<activeRecipes>
<!--dep: rewrite-migrate-java-->
<recipe>org.openrewrite.java.migrate.UpgradeToJava25</recipe>
<recipe>org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta</recipe>
<!--dep: rewrite-spring-->
<recipe>org.openrewrite.java.spring.boot4.SpringBootProperties_4_0</recipe>
<recipe>org.openrewrite.java.spring.boot4.MigrateAutoconfigurePackages</recipe>
<recipe>org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0</recipe>
<recipe>org.openrewrite.java.spring.boot4.MigrateToModularStarters</recipe>
<recipe>org.openrewrite.java.spring.boot4.RenameDeprecatedStartersManagedVersions</recipe>
<recipe>org.openrewrite.java.spring.boot4.ReplaceMockBeanAndSpyBean</recipe>
<recipe>org.openrewrite.java.spring.framework.UpgradeSpringFramework_7_0</recipe>
<recipe>org.openrewrite.java.spring.security7.UpgradeSpringSecurity_7_0</recipe>
<recipe>org.openrewrite.java.spring.kafka.UpgradeSpringKafka_4_0</recipe>
<recipe>org.openrewrite.java.spring.http.ReplaceStringLiteralsWithHttpHeadersConstants</recipe>
<recipe>org.openrewrite.java.spring.ExpandProperties</recipe>
<recipe>org.openrewrite.java.migrate.JavaBestPractices</recipe>
<recipe>org.openrewrite.java.jspecify.JSpecifyBestPractices</recipe>
<recipe>org.openrewrite.java.migrate.lang.var.UseVarForGenericsConstructors</recipe>
<recipe>org.openrewrite.java.migrate.lang.var.UseVarForGenericMethodInvocations</recipe>
<recipe>org.openrewrite.java.migrate.lang.var.UseVarForObject</recipe>
<recipe>org.openrewrite.java.migrate.lang.var.UseVarForPrimitive</recipe>
<!--dep: rewrite-static-analysis-->
<recipe>org.openrewrite.staticanalysis.CommonStaticAnalysis</recipe>
<recipe>org.openrewrite.staticanalysis.FinalizeLocalVariables</recipe>
<recipe>org.openrewrite.staticanalysis.FinalizeMethodArguments</recipe>
<recipe>org.openrewrite.staticanalysis.FinalizePrivateFields</recipe>
<recipe>org.openrewrite.staticanalysis.AvoidBoxedBooleanExpressions</recipe>
<recipe>org.openrewrite.staticanalysis.CombineSemanticallyEqualCatchBlocks</recipe>
<recipe>org.openrewrite.staticanalysis.RemoveExtraSemicolons</recipe>
<recipe>org.openrewrite.staticanalysis.StaticMethodNotFinal</recipe>
<recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe>
<!--dep: rewrite-testing-frameworks-->
<recipe>org.openrewrite.java.testing.assertj.JUnitToAssertj</recipe>
<recipe>org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ</recipe>
<recipe>org.openrewrite.java.testing.junit5.JUnit5BestPractices</recipe>
<recipe>org.openrewrite.java.testing.mockito.MockitoBestPractices</recipe>
<!--dep: rewrite-micrometer-->
<recipe>org.openrewrite.micrometer.MicrometerBestPractices</recipe>
<!--rewrite-jackson-->
<recipe>org.openrewrite.java.jackson.JacksonBestPractices</recipe>
<!--finally-->
<recipe>org.openrewrite.java.RemoveUnusedImports</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-migrate-java</artifactId>
<version>3.33.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-static-analysis</artifactId>
<version>2.33.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-testing-frameworks</artifactId>
<version>3.35.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-spring</artifactId>
<version>6.30.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-micrometer</artifactId>
<version>0.28.9</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-jackson</artifactId>
<version>1.22.0</version>
</dependency>
</dependencies>
</plugin>
----------------------------------------------------------
mvn rewrite:discover
[INFO] Available Styles:
[INFO] com.netflix.eureka.Style
[INFO] com.netflix.genie.Style
[INFO] org.openrewrite.java.GoogleJavaFormat
[INFO] org.openrewrite.java.IntelliJ
[INFO] org.openrewrite.java.SpringFormat
[INFO] org.openrewrite.kotlin.IntelliJ
[INFO]
[INFO] Active Styles:
[INFO]
[INFO] Active Recipes:
[INFO] org.openrewrite.java.jackson.JacksonBestPractices
[INFO] org.openrewrite.java.jspecify.JSpecifyBestPractices
[INFO] org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta
[INFO] org.openrewrite.java.migrate.JavaBestPractices
[INFO] org.openrewrite.java.migrate.lang.var.UseVarForGenericMethodInvocations
[INFO] org.openrewrite.java.migrate.lang.var.UseVarForGenericsConstructors
[INFO] org.openrewrite.java.migrate.lang.var.UseVarForObject
[INFO] org.openrewrite.java.migrate.lang.var.UseVarForPrimitive
[INFO] org.openrewrite.java.migrate.UpgradeToJava25
[INFO] org.openrewrite.java.RemoveUnusedImports
[INFO] org.openrewrite.java.spring.boot4.MigrateAutoconfigurePackages
[INFO] org.openrewrite.java.spring.boot4.MigrateToModularStarters
[INFO] org.openrewrite.java.spring.boot4.RenameDeprecatedStartersManagedVersions
[INFO] org.openrewrite.java.spring.boot4.ReplaceMockBeanAndSpyBean
[INFO] org.openrewrite.java.spring.boot4.SpringBootProperties_4_0
[INFO] org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0
[INFO] org.openrewrite.java.spring.ExpandProperties
[INFO] org.openrewrite.java.spring.framework.UpgradeSpringFramework_7_0
[INFO] org.openrewrite.java.spring.http.ReplaceStringLiteralsWithHttpHeadersConstants
[INFO] org.openrewrite.java.spring.kafka.UpgradeSpringKafka_4_0
[INFO] org.openrewrite.java.spring.security7.UpgradeSpringSecurity_7_0
[INFO] org.openrewrite.java.testing.assertj.JUnitToAssertj
[INFO] org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ
[INFO] org.openrewrite.java.testing.junit5.JUnit5BestPractices
[INFO] org.openrewrite.java.testing.mockito.MockitoBestPractices
[INFO] org.openrewrite.micrometer.MicrometerBestPractices
[INFO] org.openrewrite.staticanalysis.AvoidBoxedBooleanExpressions
[INFO] org.openrewrite.staticanalysis.CodeCleanup
[INFO] org.openrewrite.staticanalysis.CombineSemanticallyEqualCatchBlocks
[INFO] org.openrewrite.staticanalysis.CommonStaticAnalysis
[INFO] org.openrewrite.staticanalysis.FinalizeLocalVariables
[INFO] org.openrewrite.staticanalysis.FinalizeMethodArguments
[INFO] org.openrewrite.staticanalysis.FinalizePrivateFields
[INFO] org.openrewrite.staticanalysis.RemoveExtraSemicolons
[INFO] org.openrewrite.staticanalysis.StaticMethodNotFinal
[INFO]
[INFO] Found 3136 available recipes and 6 available styles.
[INFO] Configured with 35 active recipes and 0 active styles.
Snipet 1:
// arrange
final var entity = ExampleMother.wohnblockDurchgefuehrt().build();
// act
final ExampleMeldungDto result = ExampleConverter.toDto(entity); (here is no 'var')
// assert
Snipet 2:
@Test
void toEnum_Frau_Female() {
// act
final GeschlechtEnumDto result = GeschlechtConverter.toDto(Geschlecht.F);
// assert
assertThat(result).isEqualByComparingTo(GeschlechtEnumDto.F);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked FAQ and the Maven rewrite plugin configuration, then compare the active recipe list from mvn rewrite:discover with the two Java snippets. No source file or test is named, so first identify a focused reproduction for the incomplete migration behavior. Done means the recipe-ordering or repeated-visit behavior is explained and documented with the relevant limitations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100