Skip to content
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

When using multiple before templates, do not require the type present in a single before template to be present for all matches #119

Closed
timtebeek opened this issue Dec 10, 2024 · 2 comments · Fixed by #120
Assignees
Labels
bug Something isn't working

Comments

@timtebeek
Copy link
Contributor

As seen on:

The AssertEqualWithMessage rule from Picnic's EPS contains a number of different before templates, each with different argument types.

The now generated preconditions with 1.19.1 require the type from just one of those before templates to be present for all before a match.

            return Preconditions.check(
                    Preconditions.and(
                        new UsesType<>("java.util.Map", true),
                        new UsesMethod<>("org.testng.Assert assertEquals(..)", true)
                    ),
                    javaVisitor
            );

Ideally we adjust the preconditions such that the UsesType Map is either optional, or fully absent, unless that's present on all before templates.

@knutwannheden
Copy link
Contributor

Interesting! I wasn't aware of this possibility. I think we should then indeed skip the UsesType unless all before templates have it. Is that the only thing that needs to be changed to make these Refaster recipes wirk?

@timtebeek timtebeek moved this to Backlog in OpenRewrite Dec 11, 2024
@timtebeek
Copy link
Contributor Author

I haven't explored this yet, but I think that's the only change indeed. Note that the input template here as a mix of primitives and classes; any adjustments would need to account for that, but I think it ought to be straightforward. I've asked the team to have a look.

@jevanlingen jevanlingen self-assigned this Dec 11, 2024
@jevanlingen jevanlingen linked a pull request Dec 11, 2024 that will close this issue
3 tasks
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenRewrite Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants