Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RCS1211 #1095

Merged
merged 10 commits into from
Jul 12, 2023
Merged

Fix RCS1211 #1095

merged 10 commits into from
Jul 12, 2023

Conversation

jamesHargreaves12
Copy link
Contributor

When removing unnecessary else blocks we need to also check if it conflicts with any other switch blocks (If the else is located at the top level of a switch selection).
e.g. in the following example, we cannot apply RCS1211 to remove the else.

        switch(i)
        {
            case 0:
                if(flag)
                {
                    var z = 1;
                    return z;
                }   
                break;
            case 1:
                if(flag)
                {
                    var y = 1;
                    return y;
                }
                else
                {
                    var z = 1;
                    return z;
                }
        }

The logic here is identical to removing the braces around the switch statements and so I just refactored that method out into its own helper class.

@josefpihrt
Copy link
Collaborator

@jamesHargreaves12 sorry the late review.

@josefpihrt josefpihrt merged commit aa0bde3 into dotnet:main Jul 12, 2023
Haarmees pushed a commit to Haarmees/Roslynator that referenced this pull request Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants