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

Generic.WhiteSpace.ScopeIndent false positives with nested switch indentation and case fall-through #2502

Closed
wants to merge 1 commit into from

Conversation

klausi
Copy link
Contributor

@klausi klausi commented May 12, 2019

When you have a nested switch statement without break statements then the scope indent sniff gets confused. Here is a testcase to demonstrate the problem, I have not found a solution yet.

@gsherwood
Copy link
Member

The problem is that the return statements are being run twice, closing the CASE statement (as they should) but also the containing SWITCH. That leaves the indent in a bit of a mess.

I think I've found the problem and I'm testing a fix now.

@gsherwood gsherwood changed the title fix(ScopeIndent): Fix false positives with nested switch indentation Generic.WhiteSpace.ScopeIndent false positives with nested switch indentation and case fall-through May 13, 2019
@gsherwood gsherwood added this to the 3.5.0 milestone May 13, 2019
gsherwood added a commit that referenced this pull request May 13, 2019
… nested switch indentation and case fall-through
@gsherwood
Copy link
Member

The sniff was checking the indent in front of the return statement in one loop, then checking the return statement itself in the next loop. This is fine, but it ended up closing the scope of the CASE statement twice, which actually closed the scope of the SWITCH statement the second time.

I've added a test case and a fix here: 802e6ef

Your test case is now passing for me, although it would still be great if you were able to test the fix as well.

Thanks for reporting this.

@gsherwood gsherwood closed this May 13, 2019
@klausi
Copy link
Contributor Author

klausi commented May 13, 2019

Thanks a lot Greg! I was trying to get into this sniff myself and thought closing the scope twice was correct, but your fix is working as intended!

@klausi klausi deleted the switch-indent branch May 13, 2019 19:49
@klausi
Copy link
Contributor Author

klausi commented May 13, 2019

And found another bug with this sniff, opened #2504

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants