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

AssertJ Refaster rules for Iterator#hasNext() #1088

Open
knutwannheden opened this issue Mar 14, 2024 · 3 comments
Open

AssertJ Refaster rules for Iterator#hasNext() #1088

knutwannheden opened this issue Mar 14, 2024 · 3 comments

Comments

@knutwannheden
Copy link

Running the JUnitToAssertJRules across some code I noticed that AssertThatIsTrue and AssertThatIsFalse transformed some JUnit assertTrue() and assertFalse() calls:

image

It seems like it would be a nice addition to have specific rules calling AbstractIteratorAssert#hasNext() and AbstractIteratorAssert#isExhausted() instead.

The example was found in hibernate/hibernate-tools: https://github.com/hibernate/hibernate-tools/blob/10431fc27866d295be9d2062ffdc9b1cd9099c16/jbt/src/test/java/org/hibernate/tool/orm/jbt/util/NativeConfigurationTest.java#L242-L247

@knutwannheden
Copy link
Author

I suppose there would be a lot more interesting rules of this type that could be added. String#contains(CharSequence) comes to mind.

@knutwannheden
Copy link
Author

Adding these type of rules to AssertJRules probably makes more sense.

@timtebeek
Copy link
Contributor

In general this is a nice overview of recommended replacements for better assertions:
https://next.sonarqube.com/sonarqube/coding_rules?open=java%3AS5838&rule_key=java%3AS5838

On our side we're tackling these through

But could be nice to have these covered with Refaster rules as well, for that early feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants