'Condition always true' raised in error

Sonarqube ist reporting an error for the condition marked below:
Change this condition so that it does not always evaluate to ‘true’; some subsequent code is never executed.

        if (keytarget != null || keysource != null)
        {
                if (keytarget != null && keysource == null)
                {
                    some Code
                }
                else if (keytarget == null && 
                        keysource != null)  // issue reported here
                {
                    some Code
                }
                else
                {
                    some Code
                }
            }
        }

Hi,

Welcome to the community!

FYI, I’ve edited your post for (hopefully!) improved clarity. The bolding you initially tried to use to indicate the questionable code doesn’t work inside the code markup.

In line number 1, you test keytarget != null || keysource != null. So of the 2 values one of them must be non-null. You don’t enter the if if both are null. So then:

 
HTH,
Ann