-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conflict between Generic.WhiteSpace.ScopeIndent and PSR2.Methods.FunctionCallSignature in a match block #3255
Comments
FYI: I haven't found a solution yet, but from my initial investigation, I get the impression that when @gsherwood You are way more familiar with this sniff than me. Can you think of a quick solution of shall I continue to look into it ? |
@jrfnl I'll take a look at this report now and get back to you |
This is the debug output:
Exact indent checking is turned off during the processing of the return statement, as it should be. But the match block is a new scope, so exact indent checking looks like it's reenabled there. I'm not sure what tests cases are going to fail if I ignore the exact matching for the match block, but I'll guess we'll find out :) |
It broke what I thought it might, and shows that this sniff needs a stack for temporarily disabling exact indent checking. Here is the failing test:
Exact checking is disabled inside the array, which means you can now do anything you want in there. It need to revert to exact matching while inside a new scope, then back to ignoring that when it leaves the scope. Will play around and see how best to fix this. |
A stack isn't what's needed here. This sniff would need to detect function calls and disable exact checking of scope blocks when they are arguments of a function call, which might work by just checking if the scope is inside parenthesis and turning things off. Will try that. |
That seems to have worked. I'll clean things up and commit a fix a bit later. |
…hods.FunctionCallSignature in a match block (ref #3255)
…hods.FunctionCallSignature in a match block (ref #3255)
I've pushed up a fix for this. Thanks for reporting it, and for testing this before it got released. |
Works for me. Thank you! |
Thanks @gsherwood for taking that one on. I've been trying to think of more test cases with named parameters, match expressions and constructor property promotion for the ScopeIndent sniff, but with simple code snippets, it seems to work just fine. 🤞 It will also do so with more complex ones... |
Describe the bug
The two sniffs in subject conflict if applied to a
match
block.Code sample
Custom ruleset
None
To reproduce
After fixing, the file looks like this:
Expected behavior
The original formatting is considered valid and isn't attempted to be fixed.
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: