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

Indenting rules for arrays and case/default statements are incorrect #1

Open
tdmalone opened this issue Nov 1, 2017 · 4 comments
Open

Comments

@tdmalone
Copy link
Contributor

tdmalone commented Nov 1, 2017

Rule:

Generic.WhiteSpace.ScopeIndent.IncorrectExact

Code:

$var = [
  1, // line 31
  2, // line 32
  3, // line 33
];

Result:

     31 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
        |       |     2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
     31 | ERROR | [x] Array item not aligned correctly; expected 4 spaces but
        |       |     found 2
        |       |     (WordPress.Arrays.ArrayIndentation.ItemNotAligned)
     32 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
        |       |     2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
     32 | ERROR | [x] Array item not aligned correctly; expected 4 spaces but
        |       |     found 2
        |       |     (WordPress.Arrays.ArrayIndentation.ItemNotAligned)
     33 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
        |       |     2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
     33 | ERROR | [x] Array item not aligned correctly; expected 4 spaces but
        |       |     found 2

Desired Result:

Should expect 2 spaces for the array item, and 0 for the line.
It seems to be getting confused and thinking there's an extra 2 spaces there?

@tdmalone
Copy link
Contributor Author

tdmalone commented Nov 1, 2017

High pri because this is likely to be affecting current work

@tdmalone
Copy link
Contributor Author

tdmalone commented Nov 3, 2017

I think this is going to be complicated to look into. I am excluding three troublesome rules for now:

<exclude name="WordPress.Arrays.ArrayIndentation.ItemNotAligned"/>
<exclude name="WordPress.Arrays.ArrayIndentation.MultiLineArrayItemNotAligned"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
    <properties>
      <property name="exact" value="false"/>
    </properties>
</rule>

@tdmalone
Copy link
Contributor Author

tdmalone commented Nov 6, 2017

Two additional rules temporarily excluded due to incorrect indentation problems:

<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent"/>

@tdmalone tdmalone changed the title Indenting rules for multi-line short array syntax are incorrect Indenting rules for arrays and case/default statements are incorrect Nov 6, 2017
@tdmalone
Copy link
Contributor Author

tdmalone commented Nov 6, 2017

Possible food for thought: squizlabs/PHP_CodeSniffer#761
i.e. we might have conflicting indentation rules - including from upstream.

@tdmalone tdmalone removed their assignment May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant