False positive - squid:S2698 - JUnit5 Assertion

java
(Florin Asăvoaie) #1

Versions Used

  • SonarQube Community 7.6 (build 21501)
  • SonarJava Languages 5.11 (build 17289)
  • SonarQube Scanner for Gradle 2.7
  • Gradle 5.2.1
  • JUnit 5.3.1

Code Sample

package com.test;

import org.junit.jupiter.api.Test;

import javax.ws.rs.core.Application;

import static org.junit.jupiter.api.Assertions.*;

class MyApplicationTest {
    @Test
    void testMyApplication() {
        assertAll("...",
            () -> assertDoesNotThrow(MyApplication::new, "My message"),
            () -> assertTrue(Application.class.isAssignableFrom(MyApplication.class), "Another message")
        );
    }
}

For some reasons, squid:S2698 gets triggered at assertDoesNotThrow, although, as you can clearly see, the message is there.

Thanks,
Florin.