Scalafix rules for adding clues and using expect.same
#164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some users would rather skip the extra troubleshooting step of adding
clue
to failing expectations. This PR adds two scalafix rules:AddClueToExpect
wraps the contents of anexpect
call inclue
. It is written to be idempotent, and attempts to only addclue
where useful.RenameExpectToExpectSame
renamesexpect(a == b)
toexpect.same(a, b)
.It's up to users whether they'd like to do this or not (peppering code with
clue
is their preference), so these rules should be applied manually.Since testing the clue rule required version
0.9.0
, I split out the rule tests into different SBT modules, similarly to what's done in cats-effect.We can add the following docs to the migration guide. This is linked on the website, so should be discoverable:
Example migration guide
The
expect
function now uses clues to print useful error messages. You can read more aboutclue
in the expectations docs. If you'd prefer to skip the extra troubleshooting step of addingclue
to failing expectations, you can addclue
to all existing expectations using scalafix.The
expect.same
andexpect.eql
functions don't use clues. If you wish, you can replace expectations of the formexpect(a == b)
withexpect.same(a, b)
using scalafix. Do this before adding clues to the expectations.