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

PSR2.Methods.FunctionCallSignature broken with tab indentation #3466

Closed
dereuromark opened this issue Nov 8, 2021 · 4 comments
Closed

PSR2.Methods.FunctionCallSignature broken with tab indentation #3466

dereuromark opened this issue Nov 8, 2021 · 4 comments

Comments

@dereuromark
Copy link
Contributor

 176 | ERROR | [x] Opening statement of multi-line function call not
     |       |     indented correctly; expected 0 spaces but found
     |       |     3
     |       |     (PSR2.Methods.FunctionCallSignature.OpeningIndent)
 177 | ERROR | [x] Multi-line function call not indented correctly;
     |       |     expected 7 spaces but found 4
     |       |     (PSR2.Methods.FunctionCallSignature.Indent)
 178 | ERROR | [x] Multi-line function call not indented correctly;
     |       |     expected 7 spaces but found 4
     |       |     (PSR2.Methods.FunctionCallSignature.Indent)
 179 | ERROR | [x] Multi-line function call not indented correctly;
     |       |     expected 7 spaces but found 4
     |       |     (PSR2.Methods.FunctionCallSignature.Indent)
 180 | ERROR | [x] Multi-line function call not indented correctly;
     |       |     expected 7 spaces but found 4
     |       |     (PSR2.Methods.FunctionCallSignature.Indent)

on

			// We only want cases from here on in.
			if ($type !== 'case') {
				continue;
			}

			$nextCode = $phpcsFile->findNext( // line 176
				T_WHITESPACE,
				$tokens[$nextCase]['scope_opener'] + 1,
				$nextCloser,
				true,
			);

Bug is visible in https://github.com/php-fig-rectified/psr2r-sniffer/runs/4141026695?check_suite_focus=true as well as the changes applied by fixer in https://github.com/php-fig-rectified/psr2r-sniffer/compare/show-bug

.../devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/ControlStructures/SwitchDeclarationSniff.php  5      0
.../data/www/git/psr2r-sniffer/PSR2R/Sniffs/ControlStructures/ConditionalExpressionOrderSniff.php  FAILED TO FIX
.../work/devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/ControlStructures/UnneededElseSniff.php  FAILED TO FIX
...rk/devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/Commenting/DocBlockVarWithoutNameSniff.php  FAILED TO FIX
.../data/www/git/psr2r-sniffer/PSR2R/Sniffs/Commenting/FullyQualifiedClassNameInDocBlockSniff.php  FAILED TO FIX
/var/work/devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/Commenting/DocBlockParamSniff.php       FAILED TO FIX
...work/devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php  FAILED TO FIX
/var/work/devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/Namespaces/UnusedUseStatementSniff.php  FAILED TO FIX
/var/work/devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/Classes/ClassCreateInstanceSniff.php    7      0
/var/work/devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/PHP/ListCommaSniff.php                  FAILED TO FIX
/var/work/devilbox/data/www/git/psr2r-sniffer/PSR2R/Sniffs/PHP/SingleQuoteSniff.php                4      0

The changes are breaking indentation completely. Also fails to fix, as then afterwards other sniffs are broken due to invalid changeset.

@jrfnl
Copy link
Contributor

jrfnl commented Nov 8, 2021

@dereuromark Did you mean to report this to the PSR2R repo ? Sounds to me more like a misconfigured ruleset than a problem with the sniff itself.
I use this sniff in tab-based codebases all the time without a problem.

@dereuromark
Copy link
Contributor Author

dereuromark commented Nov 8, 2021

It might be out of sync then as it extends the original one, but I will double check then, thanks.

namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods;

class FunctionCallSignatureSniff extends PEARFunctionCallSignatureSniff

@dereuromark
Copy link
Contributor Author

dereuromark commented Nov 8, 2021

No, it is actually using the latest repo version of this, so the error/fails look like a real bug.
In what way did you configure it to be working as expected?

This seems to ref #1362 which would probably provide a better out of the box experience.

@dereuromark dereuromark reopened this Nov 8, 2021
@dereuromark
Copy link
Contributor Author

I see
the <arg name="tab-width" value="4"/> part is critical here, and with it it will also work without further auto detect etc.

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

No branches or pull requests

2 participants