Recipe Name:
Use isNotEmpty for checking for collection with no elements
Description:
Use isNotEmpty for checking for collection with no elements
Level:
warning
Language:
- java
Tags:
- AssertJ
- framework specific
- quality
Recipe
id: scw:assertj:idiomatic:collection-sizeNotZero version: 10 metadata: name: Use isNotEmpty for checking for collection with no elements shortDescription: Use isNotEmpty for checking for collection with no elements level: warning language: java enabled: true tags: AssertJ;framework specific;quality search: methodcall: args: 1: value: is: methodcall: argCount: 0 name: size type: reference: matches: Collection<.*> checkInheritance: true argCount: 1 name: assertThat anyOf: - followedBy: methodcall: args: 1: value: integer: 0 argCount: 1 name: isNotEqualTo label: isNotEqualToMethodCall - followedBy: methodcall: followedBy: methodcall: args: 1: value: integer: 0 argCount: 1 name: isNotEqualTo label: isNotEqualToMethodCall name: matches: (as|describedAs) availableFixes: - doStaticImports: true name: Use idiomatic assertion actions: - rewrite: to: org.assertj.core.api.Assertions.assertThat({{{ arguments.0.qualifier }}}) - changeName: name: isNotEmpty target: label:isNotEqualToMethodCall - modifyArguments: remove: - 1 target: label:isNotEqualToMethodCall