Problem/Motivation

The Drupal.Arrays.Array rule currently has a hard line limit on 80 characters without any option to override this limit. It would be nice to have an option like the one available on the Drupal.Files.LineLength rule. This rule allows the line limit to be set via a phpcs:set:
phpcs:set Drupal.Files.LineLength lineLimit 100

or via a ruleset.xml

<rule ref="Drupal.Files.LineLength">
  <properties>
    <property name="lineLimit" value="100"/>
  </properties>
</rule>

Proposed resolution

Add a lineLimit property to the Drupal.Arrays.Array rule, defaulting to 80 characters, allowing a user to override the settings using php:set:
phpcs:set Drupal.Arrays.Array lineLimit 100

or via a ruleset.xml

<rule ref="Drupal.Arrays.Array">
  <properties>
    <property name="lineLimit" value="100"/>
  </properties>
</rule>

Comments

Arkener created an issue. See original summary.

Arkener’s picture

Status: Active » Needs review
klausi’s picture

Status: Needs review » Needs work

The coding standards explicitly say you must use 80 characters at https://www.drupal.org/docs/develop/standards/coding-standards#array

Despite that I think the config option does not hurt and we can accept this feature request. Thanks for your PR, it mostly looks good. Left some minor comments there.

Arkener’s picture

Status: Needs work » Needs review

I've updated the PR with fixes for the given feedback.

  • klausi committed 0b2dc22 on 8.x-3.x authored by Arkener
    feat(Array): Add configurable line limit to Array sniff (#3099288 by...
klausi’s picture

Status: Needs review » Fixed

Merged!

Thanks a lot Arkener, you are on fire! Keep those Coder contributions coming and let me know if you need any help :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.