Recipe Name:
Use isNotEqualTo instead of !equals isTrue
Description:
Use isNotEqualTo instead of !equals isTrue
Level:
warning
Language:
  • java
Tags:
  • AssertJ
  • framework specific
  • quality
Recipe
id: scw:assertj:idiomatic:isNotEqualTo-methodcall-true
version: 10
metadata:
  name: Use isNotEqualTo instead of !equals isTrue
  shortDescription: Use isNotEqualTo 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:
                  prefixExpression:
                    operand:
                      methodcall:
                        argCount: 1
                        name: equals
                    operator: '!'
          name: assertThat
          label: assertThatMethodCallDirect
          type: org.assertj.core.api.Assertions
    - "on":
        methodcall:
          name:
            matches: as|describedAs
          "on":
            methodcall:
              args:
                1:
                  value:
                    is:
                      prefixExpression:
                        operand:
                          methodcall:
                            argCount: 1
                            name: equals
                        operator: '!'
              name: assertThat
              label: assertThatMethodCallIndirect
              type: org.assertj.core.api.Assertions
availableFixes:
- name: Use idiomatic assertion
  actions:
  - modifyArguments:
      rewrite:
        1: '{{{operand.qualifier}}}'
      target: label:assertThatMethodCallDirect
  - modifyArguments:
      rewrite:
        1: '{{{operand.qualifier}}}'
      target: label:assertThatMethodCallIndirect
  - changeName:
      name: isNotEqualTo
  - modifyArguments:
      applyIf:
        label:
          is:
            methodcall: {}
          labelName: assertThatMethodCallDirect
      insert:
        1: '{{{ qualifier.arguments.0.operand.arguments }}}'
      target: self
  - modifyArguments:
      applyIf:
        label:
          is:
            methodcall: {}
          labelName: assertThatMethodCallIndirect
      insert:
        1: '{{{ qualifier.qualifier.arguments.0.operand.arguments }}}'
      target: self