-
Notifications
You must be signed in to change notification settings - Fork 110
Description
Refactor existing code that currently uses the some collection matcher combined with a subsequent count check to verify the number of elements satisfying a condition. We should replace these instances with the newly introduced atLeastOne
and atLeastTwo
matchers (introduced in #3411).
Switching to the atLeastOne
and atLeastTwo
matchers offers two key benefits:
Performance: By moving the element count condition to the preamble of the matching rule, we can reduce the number of false positives and improve overall matching performance. This is because the matcher can short-circuit the evaluation if the minimum required number of elements is not found.
Code Readability: Using the dedicated atLeastOne
and atLeastTwo
matchers makes the intent of the code clearer and more concise, improving readability and maintainability. It directly expresses the requirement for a minimum number of matching elements.