Sonar does not accept null check via method

676 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.