Skip to content

Fix RCS1211#1095

Merged
josefpihrt merged 10 commits intodotnet:mainfrom
jamesHargreaves12:fix/RCS1211
Jul 12, 2023
Merged

Fix RCS1211#1095
josefpihrt merged 10 commits intodotnet:mainfrom
jamesHargreaves12:fix/RCS1211

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.

jamesHargreaves12 and others added 4 commits July 12, 2023 18:08
…lper.cs

Co-authored-by: Josef Pihrt <josef@pihrt.net>
…lper.cs

Co-authored-by: Josef Pihrt <josef@pihrt.net>
…lper.cs

Co-authored-by: Josef Pihrt <josef@pihrt.net>
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