title: Eclipse - Sonar S2629 possible false positive with new String
body: <p>I'm using latest Eclipse and Sonar plugin</p>
  
  <p>In <a href="https://stackoverflow.com/questions/7952154/spring-resttemplate-how-to-enable-full-debugging-logging-of-requests-responses">answer</a> for logging there's the following line:</p>
  
  <pre><code>log.debug("Request body: {}", new String(body, "UTF-8"));
  </code></pre>
  
  <p>Which should create String only if in DEBUG level:</p>
  
  <pre><code>/**
   * Log a message at the DEBUG level according to the specified format
   * and argument.
   * &lt;p/&gt;
   * &lt;p&gt;This form avoids superfluous object creation when the logger
   * is disabled for the DEBUG level. &lt;/p&gt;
   *
   * @param format the format string
   * @param arg    the argument
   */
  public void debug(String format, Object arg);
  </code></pre>
  
  <p>But Sonar is marking it as <code>squid:S2629</code>:</p>
  
  <blockquote>
    <p>"Preconditions" and logging arguments should not require evaluation (squid:S2629)</p>
  </blockquote>
  
  <p>And give examples with concatenation</p>
  
  <blockquote>
    <p>logger.log(Level.DEBUG, "Something went wrong: " + message);  // Noncompliant; string concatenation performed even when log level too high to show DEBUG messages</p>
  </blockquote>
  
  <p>Is it a false positive sonar warning or am I missing something?</p>
  
  <p>This isn't a duplicate of <a href="https://stackoverflow.com/questions/42388341/built-in-string-formatting-vs-string-concatenation-as-logging-parameter">this question</a> which is generally asking about the rule concept, which is concatenation, but not formatting with creating object as <code>new String</code></p>
  
  <p>Also <a href="https://dba-presents.com/index.php/jvm/java/120-use-the-built-in-formatting-to-construct-this-argument" rel="nofollow noreferrer">link</a> of an answer says creating <code>new Date()</code> isn't creating an issue with built in format:</p>
  
  <blockquote>
  <pre><code>public static void main(String[] args) {
      LOGGER.info("The program started at {}", new Date());
  }
  
  }
  </code></pre>
    
    <p>Logging this way, you avoid performance overhead for strings concatenation when nothing should be actually logged.</p>
  </blockquote>