Sonar does not honor Localizable attribute for rule S4055

Even if I explicitly mark a parameter as not needing localization, sonarqube still maintains that I should be using a resource string (S4055)

public void DoWork()
{
    LogMessage(
        "Debug", // This should *not* raise S4055
        "My debug message" /* This is fine if it warns */);
}

public void LogMessage(
    [Localizable(false)]string messageType, 
    string actualMessage)
{
    switch (messageType)
    {
        case "Debug":
            // handle debug
            break;
        case "Trace":
            // etc.
            break;
    }
}

Even if I use a constant for the messageType argument like so

LogMessage(MessageTypes.Debug, "My message");

Sonarlint/qube complains

Hi @Isaks

Thank you for reporting the issue.
We can confirm the false positive. I`ve created an issue on sonar-dotnet and you can track the progress here: S4055 FP: Localizable attribute with false argument in constructor · Issue #4502 · SonarSource/sonar-dotnet · GitHub

Thanks,
Čaba

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