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

Add refaster recipes to simplify expected value #475

Closed
wants to merge 12 commits into from

Conversation

timo-abele
Copy link
Contributor

What's changed?

3 simple refaster recipes added

What's your motivation?

salvaging the changes in #472
adding missing transformations I noticed.

Anything in particular you'd like reviewers to focus on?

These recipes are simpler that the ones in #472: they don't need generics and should work in Java 8. But each test yields:

Recipe was expected to make a change but made no changes.

Anyone you would like to review specifically?

@timtebeek

Have you considered any alternatives or workarounds?

SimplifyChainedAssertJAssertion could probably be extended to cover these cases, but I think refaster is the appropriate level of complexity

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@timo-abele timo-abele force-pushed the simple-refaster-recipes branch from 328ac47 to 2fdafa0 Compare February 6, 2024 23:45
timtebeek and others added 2 commits February 7, 2024 01:23
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek timtebeek added the recipe Recipe request label Feb 7, 2024
public class SimplifyToIsZero {

@BeforeTemplate
void before(Integer i) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want to use primitive types in the method signatures.

Copy link
Contributor Author

@timo-abele timo-abele Feb 7, 2024

Choose a reason for hiding this comment

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

I tried it for both "Integer" recipes, but still get "Recipe was expected to make a change but made no changes." for all three tests.

@timtebeek timtebeek removed their request for review March 15, 2024 10:26
@timtebeek timtebeek self-requested a review June 14, 2024 12:08
timtebeek and others added 2 commits June 14, 2024 14:14
…ertExpectationsTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek
Copy link
Contributor

Had another quick look after applying some small changes, but the before matcher in the generated recipes is failing to match on the hihglighted line.

image

image

Any insights there @knutwannheden ? Seems like a good use case to do this type of simplification with Refaster recipes.

@timtebeek
Copy link
Contributor

timtebeek commented Jun 15, 2024

Hi @timo-abele ; I've started two new efforts to (better) leverage the work done by our friends at Picnic:

I believe that could replace the recipes you've added here, given that theirs are already similar:

Would you agree with closing this effort and instead replying on the upstream EPS project for these improvements?

@timtebeek
Copy link
Contributor

Closing this effort for now, as we need an upstream fix in rewrite-templating first, and in parallel we also have this PR that might cover some of the same

Note that the work here is much appreciated though! It's just the generics that are tripping us up to merge this as-is without additional effort put into openrewrite/rewrite-templating#91 first.

Hope to revisit as soon as support is there though, and linking this issue into that one to be notified.

@timtebeek
Copy link
Contributor

Upstream we've seen a fix introduced

That means we now should see results from the existing ErrorProne Support recipes we pull in

- tech.picnic.errorprone.refasterrules.AssertJBigDecimalRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJBigIntegerRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJBooleanRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJByteRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJCharSequenceRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJDoubleRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJFloatRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJIntegerRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJLongRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJNumberRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJPrimitiveRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJShortRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJStringRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJThrowingCallableRulesRecipes

That reduces the need to reimplement them here. Thanks again for uncovering that we had an issue which is now solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants