KeySetAbsentAssertion¶
Issue ID KeySetAbsentAssertion ·
Severity Warning ·
Category Usability ·
Default on
Flags assertThat(map.keys).doesNotContain(k) — checking key absence by
materialising the key set. Use Assert<Map<K, V>>.doesNotContainKey(k)
directly.
Why¶
The Iterable.doesNotContain form produces a generic message about a Set<K>.
doesNotContainKey is purpose-built for the same intent, names the map in the
failure, and reads more clearly at the call site.
Example¶
Quick fix¶
Yes — the IDE rewrites
assertThat(map.keys).doesNotContain(k) to assertThat(map).doesNotContainKey(k)
and adds assertk.assertions.doesNotContainKey.