Recipe Name:
Use isEmpty for checking empty Collection
Description:
Use isEmpty for checking empty Collection
Level:
warning
Language:
  • java
Tags:
  • AssertJ
  • framework specific
  • quality
Recipe
id: scw:assertj:idiomatic:collection-isEmpty-true
version: 10
metadata:
  name: Use isEmpty for checking empty Collection
  shortDescription: Use isEmpty for checking empty Collection
  level: warning
  language: java
  enabled: true
  tags: AssertJ;framework specific;quality
search:
  methodcall:
    args:
      1:
        value:
          is:
            methodcall:
              name: isEmpty
              type:
                reference:
                  matches: Collection<.*>
                checkInheritance: true
    argCount: 1
    name: assertThat
    anyOf:
    - followedBy:
        methodcall:
          argCount: 0
          name: isTrue
          label: isTrueMethodCall
    - followedBy:
        methodcall:
          followedBy:
            methodcall:
              argCount: 0
              name: isTrue
              label: isTrueMethodCall
          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: isEmpty
      target: label:isTrueMethodCall