False positive of java:S2970 if `@ExtendWith(SoftAssertionsExtension.class)` is used in parent class

I’m using SonarLint 8.0.0.63273 in IntelliJ IDEA 2022.2.4 (Ultimate Edition).

Parent class

@ExtendWith(SoftAssertionsExtension.class)
public class TestBase {

  @InjectSoftAssertions
  SoftAssertions softly;
}

Child class

class TestA extends TestBase {

  @Test
  void testA() {
    softly.assertThat(0).isEqualTo(1);
  }
}

This leads to java:S2970 false positive.

image

Hello Tomohiko,

Indeed this looks like a FP - we have an open ticket for this issue. Thanks for sharing your case, I’ve added your case to this ticket, which will help us to ensure we fix it also for this slightly more complex case with inheritance.

As a workaround until this is fixed, and if you have SonarLint linked to a SonarQube/SonarCloud instance, you can mark the issues as false positive on SQ/SC side. Alternatively, you can also temporarily disable the rule in your quality profile on SQ/SC if you find it to be too noisy at the moment.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.