MikaCredoRules.RefuteOverAssertNot (MikaCredoRules v0.1.0)

Copy Markdown View Source

Negated assertions must use refute, not assert ! or assert not.

refute expr states "this must be falsy" directly. assert !expr and assert not expr say the same thing through a negation the reader has to unwind, and they produce worse failure output than refute.

# BAD
assert !valid?(user)
assert not valid?(user)

# GOOD
refute valid?(user)

assert value not in collection is left alone. It compiles to the same AST as assert not (value in collection), and the membership spelling is idiomatic, so neither form is flagged.

Negated comparison operators are not negated expressions — assert one() !== two() is fine.

The check only runs on test files, identified by filename via the :test_files param.