- SonarJava 6.0
- SonarQube 7.9.1 LTS
Sorry for the incomplete code sample, please let me know if it needs to be improved. It happened deep inside our code.
import org.slf4j.LoggerFactory;
public class MyClass {
public void func() {
try {
} catch (final MyException e) {
LoggerFactory.getLogger(MyClass.class).error("Some error", e);
// S3457 "String contains no format specifiers"
}
}
}
It seems the reason is that Sonar mistakes the org.slf4j.Logger
’ method
public void error(String msg, Throwable t);
where the first argument is a simple string with the
public void error(String format, Object... arguments);
which indeed has format as the first argument.
Same thing with all other Logger
methods: info, debug, warn