Disallow use of System.out.println and System.err.println

  • description of the Rule
    Should use a logger instead so that a log level can be specified, log verbosity can be controlled or completely suppressed using the log configuration.

  • snippet of Noncompliant Code

    public void doSomething() {
        System.out.println("Doing Something...");
    }
  • snippet of Compilant Code (fixing the above noncompliant code)
    public void someSomething() {
        LOGGER.debug("Doing Something...");
    }
  • external references and/or language specifications
  • type : Code Smell
  • tags . java, codesmell

Such a rule already exists:
https://rules.sonarsource.com/java/RSPEC-106

4 Likes