Recipe Name:
JUnit 4: assertEquals suspicious order of arguments (with message)
Description:
Suspicious argument values for 'expected' and 'actual'
Level:
warning
Language:
  • java
Tags:
  • testing
  • framework specific
  • JUnit 4
  • quality
Recipe
id: scw:java:junit4:assertEquals-suspicious-order
version: 10
metadata:
  name: 'JUnit 4: 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 4;quality
search:
  methodcall:
    args:
      1:
        value:
          not:
            is:
              literal: {}
      2:
        value:
          is:
            literal: {}
    argCount: 2
    name: assertEquals
    type: org.junit.Assert
availableFixes:
- name: Swap arguments 'actual' and 'expected'
  actions:
  - rewrite:
      to: assertEquals({{{arguments.1}}}, {{{arguments.0}}})
      target: self