S3626 Does not detect redudent jump statement

Rule S3626: Jump statements should not be redundant tries to detect jump statements (continue) statements that are redundant.

If we look to the following example:

public class NonCompliant
{
    void Continue(IEnumerable<int> numbers)
    {
        foreach (var n in numbers)
        {
            if (n is not 42) continue; // FN
        }
    }
}

The continue statement is redundant, but not detected. If we change n is not 42 to n != 42, the rule works as expected. Apparently the is not pattern matching is not taken into consideration.

Reported by SonarAnalyzer.CSharp v10.17.0.131074

Anyone?

Hi,

This is flagged for the language experts. Hopefully they’ll be along soon (but TBH, they’ve got quite a backlog :frowning: )

 
Ann