java:S106 Standard outputs should not be used directly to log anything - not reported in Test code

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube - 8.6.1, Scanner, Plugin: gradle plugin: id “org.sonarqube” version “3.0”, java 11, Gradle 6.8.1)

I use SQ developer edition and have PR decoration enabled in my GitHub project. Project is Java and compiled using Gradle.

Issue: SonarQube doesn’t report issue on System.out.println statement being used in test code. I have the following test in src/test/java test :

@Test
    void shouldReportSonarIssue() {
        System.out.println("Sout is forbidden!!!");
        assertThat("test").isEqualTo("test");
    }

After SQ analysis issue java:S106 is not reported on code above, but in the same time such issue is reported if it appears in main code.

Is this a bug? Is it possible to reconfigure it somehow?

Thats by design, rules are either for main code or for test code

2 Likes

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