must
Rejects the elements of this list that predicate answers false for.
Every rejected element becomes one entry in the report, named and located when Konsist can say where it is. An empty list rejects nothing and is not an error: a place that fills up over time holds no declarations until it does.
There is no Sequence overload. Konsist's sequence queries end with .toList(), and a constraint has to hold every rejection at once anyway to report them in walk order.
Example 1: every use case exposes invoke
"has an invoke function".konsist {
classes().withNameEndingWith("UseCase")
.must { klass -> klass.hasFunction { it.name == "invoke" } }
}Content copied to clipboard
Example 2: a query that is not about classes
konsist {
functions().must { it.hasPublicOrDefaultModifier }
}Content copied to clipboard
Parameters
predicate
what has to hold. true keeps the element, false rejects it.