Skip to content

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

Merged
timtebeek merged 6 commits intoopenrewrite:mainfrom
Laurens-W:main
Aug 5, 2024
Merged

Convert assertTrue(false, String) and assertFalse(true, String) with fail(String)#558
timtebeek merged 6 commits intoopenrewrite:mainfrom
Laurens-W:main

Conversation

@Laurens-W
Copy link
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

@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
Copy Markdown
Member

@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
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