ChromatixAU / phpcs-config-chromatix

Chromatix custom config for phpcs. Based heavily on the WordPress Coding Standards but with some of our own too.
https://www.chromatix.com.au
MIT License
1 stars 0 forks source link

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

Open tdmalone opened 6 years ago

tdmalone commented 6 years ago

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 commented 6 years ago

High pri because this is likely to be affecting current work

tdmalone commented 6 years ago

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 commented 6 years ago

Two additional rules temporarily excluded due to incorrect indentation problems:

<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent"/>
tdmalone commented 6 years ago

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