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