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

refaster for assertThat(a == b) #1078

Merged
merged 2 commits into from
Nov 28, 2019
Merged

Conversation

iamdanfox
Copy link
Contributor

Before this PR

I just came across this line of code:

assertThat(someAtomicLong.get() == MAX_QUEUE_SIZE).isTrue()

Which is bad because if the assertion ever fails, the dev will get an error message like "false did not equal true".

After this PR

==COMMIT_MSG==
refaster will automatically fix up assertions between primitives (a == b) to provide better error messages
==COMMIT_MSG==

Possible downsides?

  • we might get the expected / actual the wrong way round, but I think this is still net positive.

@changelog-app
Copy link

changelog-app bot commented Nov 28, 2019

Generate changelog in changelog/@unreleased

Type

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

Description

refaster will automatically fix up assertions between primitives (a == b) to provide better error messages

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from j-baker November 28, 2019 13:37
@iamdanfox iamdanfox requested review from carterkozak and removed request for j-baker November 28, 2019 13:37
@carterkozak
Copy link
Contributor

On my todo list to write an error prone rule to make these easier. I think errror-prone would allow us to avoid the duplication, making greaterThan, lessThan, etc feasible for all types (and mixed types) without hundreds of lines of code.

👍

@bulldozer-bot bulldozer-bot bot merged commit e39cd4c into develop Nov 28, 2019
@bulldozer-bot bulldozer-bot bot deleted the dfox/primitive-equals branch November 28, 2019 14:26
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

2 participants