Add mapping for migration for joda LocalDate#677
Add mapping for migration for joda LocalDate#677YarochkinMichael wants to merge 31 commits intoopenrewrite:mainfrom
Conversation
|
The update issue is fixed by the second commit |
|
Add LocalDateTime mapping |
| } | ||
| MethodTemplate template = AllTemplates.getTemplate(original); | ||
| if (template == null) { | ||
| //is it a better way to print logs? |
There was a problem hiding this comment.
Can you generate datatable for unhandled case?
https://docs.openrewrite.org/authoring-recipes/data-tables
or atleast use ExecutionContext messaging for unhandled case.
https://javadoc.io/doc/org.openrewrite/rewrite-core/8.19.0/org/openrewrite/InMemoryExecutionContext.html
Not sure how big your repo is but the datatable will be very useful for large repos.
There was a problem hiding this comment.
Can you give me example usage of how to print log line please?
There was a problem hiding this comment.
Hi @YarochkinMichael 👋 you can find out documentation on how to generate data tables from recipes here https://docs.openrewrite.org/authoring-recipes/data-tables#generating-the-data-table
| } | ||
| }; | ||
|
|
||
| private JavaTemplate build(JavaTemplate.Builder builder) { |
| @@ -43,12 +43,16 @@ void migrateJodaTime() { | |||
| java( | |||
There was a problem hiding this comment.
Could you add a test case for each template? This will at least ensure basic verification for each one.
FYI: If you use GitHub Copilot or ChatGPT, you’ll be surprised at how well they generate these test cases.
There was a problem hiding this comment.
I added a no-arg constructor. locally, for testing, I have a project with examples. After I finish migration, I will have more time to move it to tests.
There was a problem hiding this comment.
Most of my code is generated by ChatGPT. ;)
There was a problem hiding this comment.
Hi @YarochkinMichael tests are crucial for us and we require a decent test coverage.
Please see our guides here on creating RewriteTests easily.
|
Add LocalTime mapping |
|
I was able to fix all my use cases. Not all Joda types are mapped, but now it is printing message about missing mapping. @amishra-u please have a look into my last commit. on my side class variables are migrated without any issues. TODO: add tests. i have a local project I was using for testing. Need to turn it into unit tests. |
src/main/java/org/openrewrite/java/migrate/joda/templates/DaysTemplates.java
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/HoursTemplates.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/SecondsTemplates.java
Outdated
Show resolved
Hide resolved
|
@amishra-u can you pls check my "fix" for class wars? |
|
Not only did the tests with my changes fail. |
Yes, it failed as expected Refer to this field to disable safeMigration a better way. |
|
Before this PR can be merged, please address the following:
Alternatively, you can create a local copy of the JAR with these changes and use it in your project, skipping the PR process. If someone else needs the same feature later, they can take over and upstream it. PS: I’m not on the maintainer list—this is just my general advice. |
|
@amishra-u My question about "safe" is more about whether it is possible just to disable it. If so, I will remove it completely. The code you see now is mostly for the test. And allow me to continue my work, of course. :) Removing the "safe" feature is a part of migration. I can extract it in a separate PR. But it makes no sense to me. |
…ng-to-joda-recipe' into add-localdate-mapping-to-joda-recipe # Conflicts: # src/main/java/org/openrewrite/java/migrate/joda/templates/PeriodTemplates.java
merge master
src/main/java/org/openrewrite/java/migrate/joda/templates/AbstractDurationTemplates.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/AbstractPeriodTemplates.java
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/AbstractPeriodTemplates.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/ChronologyTemplates.java
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/ChronologyTemplates.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/HoursTemplates.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/LocatDateTemplates.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/MinutesTemplates.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/PeriodTemplates.java
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/joda/templates/SecondsTemplates.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
Ideally we see the changes from #676 adopted here, or after this is merged. |
# Conflicts: # src/main/java/org/openrewrite/java/migrate/joda/JodaTimeVisitor.java
|
As discussed, let's move this over to https://github.com/openrewrite/rewrite-joda Thanks again! |
What's changed?
Added mapping for joda LocalDate to java LocalDate
Anyone you would like to review specifically?
@amishra-u
@timtebeek
Recipe is still not updating the field as it is used further in the code.
In the snippet below, for example;
il1will not be updated,if2will.id2on line 3, then it will also be skipped, butld1updatedChecklist
No unit tests