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

Convert assertTrue(false, String) and assertFalse(true, String) with fail(String) #558

Merged
merged 6 commits into from
Aug 5, 2024

Conversation

Laurens-W
Copy link
Contributor

@Laurens-W Laurens-W commented Aug 2, 2024

What's changed?

Add recipe to rewrite assertTrue(false, "message") and assertFalse(true, "message") to fail("message")

What's your motivation?

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

Test coverage

Anyone you would like to review specifically?

@timtebeek @timo-abele

Have you considered any alternatives or workarounds?

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

@timtebeek
Copy link
Contributor

Awesome start, thanks! Did you notice this comment in the issue?

We could even implement this as a Refaster recipe, similar to what we recently added to rewrite-static-analysis in
openrewrite/rewrite-static-analysis#231

I think we can keep the tests, and replace the recipes with just a couple lines in Refaster recipes.

@timtebeek timtebeek added the recipe Recipe request label Aug 2, 2024
@timtebeek timtebeek changed the title Initial proposal Convert assertTrue(false, String) and assertFalse(true, String) with fail(String) Aug 2, 2024
@Laurens-W
Copy link
Contributor Author

Awesome start, thanks! Did you notice this comment in the issue?

We could even implement this as a Refaster recipe, similar to what we recently added to rewrite-static-analysis in
openrewrite/rewrite-static-analysis#231

I think we can keep the tests, and replace the recipes with just a couple lines in Refaster recipes.

Must admit I skimmed over that part :) I will continue working on this next week and apply the proposed changes!

@Laurens-W Laurens-W marked this pull request as ready for review August 5, 2024 14:54
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Great to see! Let's merge the two separate test classes into a single AssertLiteralBooleanToFailRecipeTest, and within those I think we write a single test that covers all four cases from a single unit test that just has the four statements in one.

Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Neat addition; thanks @Laurens-W !

@timtebeek timtebeek merged commit 60acc32 into openrewrite:main Aug 5, 2024
2 checks passed
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.

convert AssertTrue(false) to fail
2 participants