Skip to content

Conversation

@zainab-ali
Copy link
Contributor

@zainab-ali zainab-ali commented Nov 3, 2025

The RenameExpectToExpectSame scalafix rule rewrites expect(...) calls to expect.same, but misses several other rewrite opportunities:

  • It doesn't to do the same for expect.all. Users relying heavily on expect.all have no easy migration rule, and poor error messages from it.
  • It doesn't apply to nested boolean assertions with && and ||. Users can wrap these in clues, but their errors and code would be cleaner if these were rewritten to weaver's and and or.
  • It doesn't apply to the cats ===

This changeset amends the rule to apply to:

  • expect.all by rewriting equality assertions into expect.same(...).and(...) calls
  • === by rewriting it to expect.eql.
  • && and || by rewriting them to expect(...).and(expect(...))
  • expect(if cond a else b) by rewriting it to if cond expect(a) else expect(b))
  • expect(a match { case b => c }) by rewriting it to a match { case b => expect(c) }

It also improves AddClueToExpect to add clues to negated statements and type applications.

@zainab-ali zainab-ali changed the title Add scalafix rule to rename expect.all to expect.same Modify RenameExpectToExpectSame scalafix rule to rewrite expect.all Nov 3, 2025
@zainab-ali zainab-ali changed the title Modify RenameExpectToExpectSame scalafix rule to rewrite expect.all Apply RenameExpectToExpectSame scalafix rule to expect.all Nov 3, 2025
@zainab-ali zainab-ali marked this pull request as draft November 6, 2025 17:34
@zainab-ali zainab-ali force-pushed the expect-all-rule branch 3 times, most recently from b0b663e to 2fe4759 Compare November 7, 2025 11:09
@zainab-ali zainab-ali marked this pull request as ready for review November 7, 2025 11:14
@zainab-ali zainab-ali changed the title Apply RenameExpectToExpectSame scalafix rule to expect.all Improve RenameExpectSameToExpect rule to apply to expect.all and more assertions Nov 7, 2025
@zainab-ali zainab-ali changed the title Improve RenameExpectSameToExpect rule to apply to expect.all and more assertions Improve RenameExpectSameToExpect rule to apply to expect.all Nov 7, 2025
@zainab-ali zainab-ali merged commit 643e8f2 into typelevel:main Nov 10, 2025
13 checks passed
@zainab-ali zainab-ali deleted the expect-all-rule branch November 10, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant