Recipe Name:
JUnit 5: assertEquals suspicious order of arguments (with message)
Description:
Suspicious argument values for 'expected' and 'actual'
Level:
warning
Language:
  • java
Tags:
  • testing
  • framework specific
  • JUnit 5
  • quality
Recipe
id: scw:java:junit5:assertEquals-suspicious-order(with-message)
version: 10
metadata:
  name: 'JUnit 5: assertEquals suspicious order of arguments (with message)'
  shortDescription: Suspicious argument values for 'expected' and 'actual'
  level: warning
  language: java
  enabled: true
  tags: testing;framework specific;JUnit 5;quality
search:
  methodcall:
    args:
      1:
        value:
          not:
            is:
              literal: {}
      2:
        value:
          is:
            literal: {}
    argCount: 3
    name: assertEquals
    type: org.junit.jupiter.api.Assertions
availableFixes:
- name: Swap arguments 'actual' and 'expected'
  actions:
  - rewrite:
      to: assertEquals({{{arguments.1}}}, {{{arguments.0}}}, {{{arguments.2}}})
      target: self