Metadrop / drupal-boilerplate

Drupal projects up and running with Docker and many other tools in minutes
28 stars 23 forks source link

PHPCS is ignoring some files #82

Closed idiazroncero closed 1 year ago

idiazroncero commented 1 year ago

I've realized that running phpqa resulted on a number of errors that didn't appear when running phpcs on its own.

This was happening because phpcs was skipping my theme-settings.php files that sit on Drupal themes, whereas phpqa was not.

I traced the origin to this pattern on phpcs.xml.dist:

<exclude-pattern>*/.settings.php</exclude-pattern>

This seems to be excluding all files that end with settings.php, as the point (.) charecter seems to be understood as in regex, meaning "any character".

This rule should ideally be able to skip settings.local.php or local.settings.php but pass theme-settings.php.

For this, the point character needs to be escaped and a new rule should be added:

I propose to change the rules as follow:

<!-- Will exclude any settings.php -->
  <exclude-pattern>*/settings.php</exclude-pattern>
<!-- Will exclude anything that ends with *.settings.php, point is escaped -->
  <exclude-pattern>*/*\.settings.php</exclude-pattern>
<!-- Will exclude anything that follows the pattern settings.ANYTHING.php -->
  <exclude-pattern>*/settings\.*\.php</exclude-pattern>

A PR has been created: #81

rsanzante commented 1 year ago

Good catch! Indeed the dot character should be escaped.

Thanks!

rsanzante commented 1 year ago

PR has been merged.