phpro / grumphp

A PHP code-quality tool
MIT License
4.14k stars 430 forks source link

git_blacklist does nothing in v0.7.2 #124

Closed ibrambe closed 8 years ago

ibrambe commented 8 years ago

When I commit a file "test.php" with one of the defined keywords, nothing seems to happen. I expect to see a warning cause there's still a var_dump in my code.

Config:

        git_blacklist:
            keywords:
                - "die("
                - "var_dump("
                - "exit;"
                - "dump("
                - "print_r"
veewee commented 8 years ago

Can you give me some additional information about the issue? I did following steps:

Actions

mkdir tmp
cd tmp
git init
composer require --dev phpro/grumphp
echo "vendor" > .gitignore
echo "<?php var_dump('ok');" > test.php

# Copy the lines to grumphp.yml file
vim grumphp.yml 

git add -A && git commit -m"Test"

Result:

You have blacklisted keywords in your commit:
test.php:1:<?php var_dump('ok');

So this tasks seems to work to me. Can you tell me how to reproduce your error?

ibrambe commented 8 years ago

This seems to work indeed:

<?php var_dump('ok');

but in my testfile, there were some new lines between the opening tag and the var_dump function and that seems to be the problem:

<?php

var_dump('ok')
veewee commented 8 years ago

It seems like there is something wrong with the internal git command that is being used:

# Sometimes this works, sometimes it doesn't:
git grep --cached -n '-e var_dump(' test.php

# This seems to always work:
git grep --cached -n -e 'var_dump(' test.php

I will try to get this one fixed later this week. Thanks for reporting!

veewee commented 8 years ago

@ibrambe A fix is underway in PR #126

ibrambe commented 8 years ago

@veewee Thanks!