Recipe Name:
Use isEqualTo instead of equals isTrue
Description:
Use isEqualTo instead of equals isTrue
Level:
warning
Language:
  • java
Tags:
  • AssertJ
  • framework specific
  • quality
Recipe
id: scw:assertj:idiomatic:isEqualTo-methodcall-true
version: 10
metadata:
  name: Use isEqualTo instead of equals isTrue
  shortDescription: Use isEqualTo instead of equals isTrue
  level: warning
  language: java
  enabled: true
  tags: AssertJ;framework specific;quality
search:
  methodcall:
    name: isTrue
    anyOf:
    - "on":
        methodcall:
          args:
            1:
              value:
                is:
                  methodcall:
                    argCount: 1
                    name: equals
          name: assertThat
          label: assertThatMethodCallDirect
          type: org.assertj.core.api.Assertions
    - "on":
        methodcall:
          name:
            matches: as|describedAs
          "on":
            methodcall:
              args:
                1:
                  value:
                    is:
                      methodcall:
                        argCount: 1
                        name: equals
              name: assertThat
              label: assertThatMethodCallIndirect
              type: org.assertj.core.api.Assertions
availableFixes:
- name: Use idiomatic assertion
  actions:
  - modifyArguments:
      rewrite:
        1: '{{{ qualifier }}}'
      target: label:assertThatMethodCallDirect
  - modifyArguments:
      rewrite:
        1: '{{{ qualifier }}}'
      target: label:assertThatMethodCallIndirect
  - modifyArguments:
      applyIf:
        label:
          is:
            methodcall: {}
          labelName: assertThatMethodCallDirect
      insert:
        1: '{{{ qualifier.arguments.0.arguments }}}'
  - modifyArguments:
      applyIf:
        label:
          is:
            methodcall: {}
          labelName: assertThatMethodCallIndirect
      insert:
        1: '{{{ qualifier.qualifier.arguments.0.arguments }}}'
  - changeName:
      name: isEqualTo