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