phpro / grumphp

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

Possible to have MND run only on changed files? #622

Closed MarkVaughn closed 5 years ago

MarkVaughn commented 5 years ago
Q A
Version GrumPHP 0.15.0
Bug? maybe
New feature? no
Question? yes
Documentation? maybe

My configuration

parameters:
  git_dir: .
  bin_dir: vendor/bin
  hooks_dir: ~
  hooks_preset: local
  stop_on_failure: true
  tasks:
    phpcs: ~
    phplint: ~
    phpmd: ~
    phpmnd: ~
    phpparser: ~
    phpstan: ~
    securitychecker: ~

Steps to reproduce:

# add grumphp to a project with hundreds of magic numbers
# modify a single php file

# Run GrumpHP:
git add -A && git commit -m"Test"
# or
./vendor/bin/grumphp run

Result:

Total of Magic Numbers: 34
Time: 547 ms, Memory: 22.00 MB

It seems all other tasks only run on the changed files, but MND runs on the whole project. Is this intentional or an oversight?

veewee commented 5 years ago

Hello @MarkVaughn,

The phpmnd package doesn't have an option to pass a list of files. Therefor it is not possible yet to run that tasks on the changed files only.

exussum12 commented 5 years ago

There is an option currently --whitelist allows you to pass a file containing file paths.

Git diff --names-only is what I use for this