phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

GrumPHP phpcs not picking up for "old" files #117

Closed Yerlix closed 8 years ago

Yerlix commented 8 years ago

I'm testing GrumPHP for Drupal, and I've downloaded Drupal Coder Sniffer (https://www.drupal.org/node/1419988) with a ruleset for phpcs. I've installed it locally, not global like they do in the guide.

Now I've noticed that for instance the dpm('test'); function is picked up when I create a new file (not known to Git) and commit it. But when I've added the same function to an old file (known to Git), GrumPHP did not show an error for it when committing.

Now I've tested it again, because I thought that GrumPHP only triggered for new files. But when I try to add some other function (for instance dsm('test') to the "new" file, which is committed now, GrumPHP shows an error on commit.

My configuration for GrumPHP:

parameters:
  git_dir: .
  bin_dir: ./vendor/bin
  tasks:
    git_commit_message:
      matchers:
          - /BT-([0-9]*)/
    phpcs:
      standard: vendor/drupal/coder/coder_sniffer/Drupal/
      ignore_patterns:
        - cfg/
        - libraries/
veewee commented 8 years ago

Can you try this again with the current dev-master? It seems like this is an issue with staged / unstaged changes. You can find more information on this issue in the tickets: #100, #103

veewee commented 8 years ago

@Yerlix This has been released in https://github.com/phpro/grumphp/releases/tag/v0.8.0 Can you verify this works for you?

Yerlix commented 8 years ago

This still does not work after updating. A new file with dpm('test') triggers an error on phpcs, while an existing file does not

Yerlix commented 8 years ago

Turns out that GrumPHP only checks .php files while I need it to check .module and .inc files.

flyke commented 7 years ago

@Yerlix add .module and .inc files in your grumphp.yml file:

tasks: phpcs: standard: vendor/drupal/coder/coder_sniffer/Drupal/ ignore_patterns:

  • cfg/
  • libraries/ triggered_by:
  • php
  • module
  • inc