False positive - squid:S2698 - JUnit5 Assertion

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.

Hi, this is indeed a false positive. Thanks for feedback and reproducer, always appreciated.
Ticket created to handle the issue :
https://jira.sonarsource.com/browse/SONARJAVA-3146

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