Sonar is not analyzing the reference objects


We are trying to fix all the sonarqube major and critical bugs in our projects. We cameup one scenario in which sonar is not analyzing the “ref” variable passed to a function. Below is the sample coe that we have and sonar is giving “(C#) Conditionally executed code should be reachable” issue.

Code sample,

public void TestExample(ref bool stop)
while (!stop)
    while (true)
        if (stop) break;

SonarQube is generating below error.

Is you see the code and the logic, it looks good, because stop is a referenced variable and it can be changes from any location in the project.

Can anyone please help me in resolving this sonar issue without excluding this file from sonar.

Hi @Himanshu_Jain

We can confirm the false positive. An issue already exists for it and you can track the progress here:

Thanks for your feedback!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.