Why #pragma warning disable S2068 does not work?

Version: SonarQube

Objective: Suppress the error S2068

What has been tried:
adding the //NOSONAR (with or without a space after //),
adding #pragma warning disable S2068 at the top of the file.

Similar question has been asked on stackoverflow:

Any suggestion how can this error be suppressed?

hi @Righen_Sawmynaden and welcome to our community.

as you see in the StackOverflow queston, you can use

[System.Diagnostics.CodeAnalysis.SuppressMessage(“Sonar Code Smell”, “S2068:Credentials should not be hard-coded”, Justification = “”)]

However, to look into the behavior you want, can you please tell me what version of the SonarCSharp plugin you’re using?

1 Like