False positive for "Squid:S2970 Add a call to 'assertAll' after all 'assertThat'" when using SoftAssertions.assertSoftly

This rule incorrectly warns that ‘assertAll’ needs to be called for AssertJ assertions in this example. Note that the static method SoftAssertions.assertSoftly calls the ‘assertAll()’ method.

I am seeing the false positive in both SonarQube version 6.7.6 and also when using the IntelliJ SonarLint plugin version

Here is a very simple example:

import org.assertj.core.api.SoftAssertions;
import org.junit.Test;

public class FalsePositiveTest {

  public void falsePositive() {
    SoftAssertions.assertSoftly(softly -> {
  } // The violation is marked here since it apparently doesn't know 'assertAll()' was called
1 Like

Hello Jeffrey,

Thank you for reporting this.
Indeed, the SoftAssertions#assertSoftly method is not handled correctly by our plugin.
I’ve created the following ticket related to this issue: SONARJAVA-3143.

Kind regards,