-
Notifications
You must be signed in to change notification settings - Fork 356
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
Upstream RemoveMethodInvocationsVisitor #4639
Conversation
* Update for rewrite 8.0 * Cosmetics * Fix a few more issues * Fix a few more test failures * Fix a few more test failures * Upgrade recipes to new `JavaTemplate` API * Replace `getRecipeList()` overrides with `@Getter(lazy = true)` property * Consistently use `latest.release` or `latest.integration` * Revert "Replace `getRecipeList()` overrides with `@Getter(lazy = true)` property" This reverts commit 897d59e79c9515564da45911ce2246934c5b1ae7. * Migrate to new `Recipe#getInitialState(ExecutionContext)` API * Polish * Fix a broken test Due to reversal of logic after inlining `doAfterVisit()` logic. * Fix another broken test We should change the `UpgradeDependencyVersion` in `rewrite-java-dependencies` so that workarounds like this are not necessary. * Fix last failing test (use `doAfterVisit()` again) --------- Co-authored-by: Sam Snyder <[email protected]>
* Update for rewrite 8.0 * Cosmetics * Fix a few more issues * Fix a few more test failures * Fix a few more test failures * Upgrade recipes to new `JavaTemplate` API * Replace `getRecipeList()` overrides with `@Getter(lazy = true)` property * Consistently use `latest.release` or `latest.integration` * Revert "Replace `getRecipeList()` overrides with `@Getter(lazy = true)` property" This reverts commit 897d59e79c9515564da45911ce2246934c5b1ae7. * Migrate to new `Recipe#getInitialState(ExecutionContext)` API * Polish * Fix a broken test Due to reversal of logic after inlining `doAfterVisit()` logic. * Fix another broken test We should change the `UpgradeDependencyVersion` in `rewrite-java-dependencies` so that workarounds like this are not necessary. * Fix last failing test (use `doAfterVisit()` again) --------- Co-authored-by: Sam Snyder <[email protected]>
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne <[email protected]>
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.NullableOnMethodReturnType?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne <[email protected]>
Use this link to re-run the recipe: https://app.moderne.io/builder/gW3xaSLWV?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne <[email protected]>
…fter porting them over from rewrite-spring with preserved history
…port for long nested method chains
rewrite-java/src/main/java/org/openrewrite/java/RemoveMethodInvocationsVisitor.java
Outdated
Show resolved
Hide resolved
rewrite-java/src/main/java/org/openrewrite/java/RemoveMethodInvocationsVisitor.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@@ -64,6 +64,7 @@ dependencies { | |||
testRuntimeOnly(project(":rewrite-java-17")) | |||
testImplementation("com.tngtech.archunit:archunit:1.0.1") | |||
testImplementation("com.tngtech.archunit:archunit-junit5:1.0.1") | |||
testImplementation("org.junit-pioneer:junit-pioneer:2.0.0") |
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 would rather use JUnit 5's built in assertThrows() unless there is some really compelling advantage to @ExpectedToFail
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've seen it in other modules, and I like the semantics of it for documenting a not-yet-implemented feature with a test.
But yeah, it does require another dep, and we can get similar functionality with assertThrows. I can swap it out when I'm at my desk later.
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 also quite like @ExpectedToFail
for tests which test something that is supposed to work but doesn't due to a bug. I use assertThrows()
when I want to test that something is supposed to throw an exception.
When the bug is fixed, all I have to do is to remove the @ExpectedToFail
annotation.
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.
sounds like @sambsnyd is outvoted here, unless I hear otherwise :)
any other review concerns for this PR, before we rebase-not-squash and merge?
@timtebeek , @knutwannheden
What's changed?
This visitor existed in rewrite-spring; I'm moving it over here (with some minor bugfixes)
https://github.com/openrewrite/rewrite-spring/blob/b0a95c850c521ebf6104c946f044ef9c1c43bd5b/src/main/java/org/openrewrite/java/spring/RemoveMethodInvocationsVisitor.java#L39
What's your motivation?
This visitor had a bug with long invocation chains which include args which are themselves long invocation chains. Also some NPE risks. I wanted to fix those, and I figure there's nothing specific to rewrite-spring in here so it makes sense to give broader reach.
It could probably also be wrapped into a recipe for convenient consumption in the future.
Anything in particular you'd like reviewers to focus on?
I added two new test cases:
removeFromWithinArguments
(verifies the bugfix I cared about)removeWithoutSelect
(annotated as expected to fail; something I noticed along the way. my src changes convert this test case from uncaught NPE to no-changes)~Next week I'll probably deprecate all the original code in rewrite-spring and adjust the impls to pass through to this class.
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
I could apply the same fixes in-place in rewrite-spring, if preferred
Any additional context
I took care to preserve git history from rewrite-spring for these files, so I'd love to not squash the PR on merge
Checklist