0

Sonar does not accept the control when we check for null via method. What can be the solution?

It only accepts when you do as follows:

if (callID == null) 
{
 throw new ArgumentNullException(nameof(callID));
}

It doesn't see it when I do it like below.

private static void a(string callID) {
            if (callID == null) {
                throw new ArgumentNullException(nameof(callID));
            }
        }

Is this a general problem for sonar? Thanks in advance.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 25 '22 at 16:07
  • A link to the error/warning (because you say "does not accept", it should be an error) to the notice that Sonar provides, like: https://rules.sonarsource.com/csharp/RSPEC-125, or just `S125` for the code that is produces by Sonar, would be nice. – Luuk Apr 25 '22 at 16:22

1 Answers1

0

I contacted the sonar team and they said this problem occurs with older versions.The version I am using is 4.30 and they asked me to upgrade it to 6.1.So,problem solved.