Skip to content

fix: 🐛 Exempt Pest test bodies from DisallowBooleanArgumentFlag. - #402

Open
mikebronner wants to merge 1 commit into
mainfrom
fix/pest-dataset-bool-flag
Open

mikebronner wants to merge 1 commit into
mainfrom
fix/pest-dataset-bool-flag

Conversation

@mikebronner

Copy link
Copy Markdown
Contributor

A Pest test closure takes its parameters from a dataset. A bool $expected there is an expected value, not a behaviour switch. Until now the sniff reported it, so consumers had to type the parameter as mixed.

The sniff now skips a closure or arrow function in one position only: the test body, which is the second argument of a global it() or test() call. A static body, \it() and an upper-case IT() are covered too.

These are still reported:

  • a closure passed to any other function, including describe() and a method named it
  • a closure nested inside a test body
  • a closure in the first argument position
  • a plain function and a method

The exceptions and ignorepattern properties work as before. The complexity pin for this sniff's own file is updated to match the new methods.

A bool parameter on the closure or arrow function passed as the test body
to a Pest it() or test() call receives a dataset value. It carries an
expected value, not a behaviour switch, so the sniff no longer reports it.
A static closure body and a \it() or \test() call are exempt too.

A closure passed to any other function, including describe() and a method
named it, still reports. So do a closure nested inside a test body, a
closure in the first argument position, a plain function and a method. The
exceptions and ignorepattern properties work as before.
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