Recipe Name:
Use isEmpty for checking for collection with no elements
Description:
Use isEmpty for checking for collection with no elements
Level:
warning
Language:
- java
Tags:
- AssertJ
- framework specific
- quality
Recipe
id: scw:assertj:idiomatic:collection-hasSizeLessThanOrEqualToZero version: 10 metadata: name: Use isEmpty for checking for collection with no elements shortDescription: Use isEmpty for checking for collection with no elements level: warning language: java enabled: true tags: AssertJ;framework specific;quality search: methodcall: args: 1: type: reference: matches: Collection<.*> checkInheritance: true argCount: 1 name: assertThat anyOf: - followedBy: methodcall: args: 1: value: integer: 0 argCount: 1 name: hasSizeLessThanOrEqualTo label: hasSizeLessThanOrEqualToMethodCall type: reference: matches: org.assertj.core.api.AbstractIterableAssert<.*> checkInheritance: true - followedBy: methodcall: followedBy: methodcall: args: 1: value: integer: 0 argCount: 1 name: hasSizeLessThanOrEqualTo label: hasSizeLessThanOrEqualToMethodCall type: reference: matches: org.assertj.core.api.AbstractIterableAssert<.*> checkInheritance: true name: matches: (as|describedAs) availableFixes: - name: Use idiomatic assertion actions: - changeName: name: isEmpty target: label:hasSizeLessThanOrEqualToMethodCall - modifyArguments: remove: - 1 target: label:hasSizeLessThanOrEqualToMethodCall