Sonarlint java:S3457 false-positive "Printf-style format strings should be used correctly"

OS: Windows 10
IDE: Netbeans 20 with Sonarlint4netbeans 3.0.1 (Uses Sonarlint-core 8.3.0.45095)
LANG: Java 17

Call to method: public void log(Level level, String msg, Throwable thrown) from java.util.logging.Logger class is tagged with “java:S3457” if the given “msg” String is literal and the literal String contains any number of single '-characters.
Below is a reduced Java source code to reproduce this.

import java.lang.logging.Logger;
import java.lang.logging.Level;

public class Tester {
    private static final Logger logger = Logger.getLogger(Tester.class.getName());
    public static void main(String[] args) {
        try {
            System.loadLibrary("THIS_LIBRARY_DOES_NOT_EXIST");
        } catch(UnsatisfiedLinkError ule) {
            logger.log( Level.SEVERE, "Can't load library \"THIS_LIBRARY_DOES_NOT_EXIST\"!", ule );
        }
    }
}

Hey there!

(upfront, we don’t maintain this, so there’s not much we can do)

It looks like v3.0.1 is using a version of our Java analyzer released in November 2022 (about a year and a half ago)

If you can reproduce this issue using the latest version of SonarQube or on SonarCloud, let us know.

Same issue but more detailed description if I use VS Code with SonarLint extension.
Error message is: Single quote “'” must be escaped.

VS Code used:
image
SonarLint extension:
image

Hello @Sami_Naatanen ,

Thanks for your report and the reproducer. I can confirm, this is a false positive in the current rule implementation. You can track the issue this ticket.

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