If a boolean expression doesn’t change the evaluation of the condition, then it is entirely unnecessary, and can be removed. If it is gratuitous because it does not match the programmer’s intent, then it’s a bug and the expression should be fixed.

Noncompliant Code Example

public void Sample(bool b, bool c, string s)
{
    var a = true;
    if (a) // Noncompliant
    {
        DoSomething();
    }

    if (b && a) // Noncompliant; "a" is always "true"
    {
        DoSomething();
    }

    if (c || !a) // Noncompliant; "!a" is always "false"
    {
        DoSomething();
    }

    string d = null;
    var v1 = d ?? "value"; // Noncompliant, d is always null
    var v2 = s ?? d; // Noncompliant, d is always null and the produced value is always equal to s. The condition to check the value of s is gratuitous.
}

Compliant Solution

public void Sample(bool b, bool c, string s)
{
    var a = true;
    if (Foo(a))
    {
        DoSomething();
    }

    if (b)
    {
        DoSomething();
    }

    if (c)
    {
        DoSomething();
    }

    var v1 = "value";
    var v2 = s;
}

See