FN on S5863: Compare an object to itself with AssertJ / SoftAssertions

Make sure to read this post before raising a thread here:

  • What language is this for: Java
  • Which rule: S5863
  • Why do you believe it’s a false-positive/false-negative: SoftAssertions do not show when object is compared to itself
  • Are you using
    • SonarQube: 9.9
    • SonarLint: Intellij 2023.2.2
      • in connected mode with SonarQube
  • How can we reproduce the problem:
class JUnit5SoftAssertionsExample {
  void junit5_soft_assertions_example() {
    String testString = "test";
    assertThat(testString).isEqualTo(testString); // shows Assertions should no compare an object to itself message
    assertSoftly(assertSoftly -> {
       assertSoftly.assertThat(testString).isEqualTo(testString); // no message
   SoftAssertions softAssertions = new SoftAssertions();
   softAssertions.assertThat(testString).isEqualTo(testString); // no message

Hello @bzadelhoff, welcome to the community!

Thanks for reporting this FN. You are right, we currently don’t support AssertJ soft assertions. I’ve created a ticket to add support, you can track it here.