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

Error prone AssertjPrimitiveComparison for primitive comparisons #1079

Merged
merged 2 commits into from
Dec 2, 2019

Conversation

carterkozak
Copy link
Contributor

@carterkozak carterkozak commented Dec 1, 2019

This check replaces several refaster rules in order to provide a
more concise, more accurate implementation.

This check supports boxed types and mixed primitive types, in addition to full support for comparisons across all primitives.

==COMMIT_MSG==
Error prone AssertjPrimitiveComparison for primitive comparisons

Prefer using AssertJ fluent comparisons over logic in an assertThat
statement for better failure output. assertThat(a == b).isTrue()
failures report 'expected true' where assertThat(a).isEqualTo(b)
provides the expected and actual values.
==COMMIT_MSG==

Possible downsides?

This check assumes the left side of a binary expression is the 'actual' value and the right side is 'expected'. This may not always be the case, but either way the resulting code will provide more actionable output on failure.

Prefer using AssertJ fluent comparisons over logic in an assertThat
statement for better failure output. assertThat(a == b).isTrue()
failures report 'expected true' where assertThat(a).isEqualTo(b)
provides the expected and actual values.

This check replaces several refaster rules in order to provide a
more concise, more accurate implementation.
@changelog-app
Copy link

changelog-app bot commented Dec 1, 2019

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Error prone AssertjPrimitiveComparison for primitive comparisons

Prefer using AssertJ fluent comparisons over logic in an assertThat
statement for better failure output. assertThat(a == b).isTrue()
failures report 'expected true' where assertThat(a).isEqualTo(b)
provides the expected and actual values.

Check the box to generate changelog(s)

  • Generate changelog entry

import javax.lang.model.type.TypeKind;


final class AssertjSingleAssertMatcher {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 I like having this separated out, I imagine there will be a lot more checks that can benefit from this

Copy link
Contributor

@iamdanfox iamdanfox left a comment

Choose a reason for hiding this comment

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

Thanks Carter!

@iamdanfox
Copy link
Contributor

Also nice to be able to delete so many refasters in one go!

@bulldozer-bot bulldozer-bot bot merged commit d643ff0 into develop Dec 2, 2019
@bulldozer-bot bulldozer-bot bot deleted the ckozak/assert branch December 2, 2019 17:07
@svc-autorelease
Copy link
Collaborator

Released 2.37.0

This was referenced Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants