the default PHPMD::ignorePatterns is to restrictive and ignores path containing the substring .git
mdesile opened this issue · comments
- PHPMD version: 2.15.0
- PHP Version: 8.2.16
- Installation type: composer
- Operating System / Distribution & Version: fedora 39
Current Behavior
my source code lives in a repository named /home/username/Projects/project1.git
the default ignorePatterns (set to array('.git', '.svn', 'CVS', '.bzr', '.hg', 'SCCS')
) matches for the filter PDepend\Input\ExclusionFilter::notRelative (in vendor/pdepend/pdepend/src/main/php/PDepend/Input/ExcludePathFilter.php on line 129) :
return (preg_match($this->relative, $path) === 0);
where $this->relative is (.git|.svn|CVS|.bzr|.hg|SCCS)i"
and $path is "/home/username/Projects/project1.git/src/Controller/RandomController.php"
Expected Behavior
While the .git directory should be ignored, a directory containing .git as a substring should not be ignored
Steps To Reproduce:
mkdir /tmp/test-project.git
cd /tmp/test-project.git
echo "<?php class lower_case{}" > test.php
composer require --dev phpmd/phpmd
./vendor/bin/phpmd test.php text controversial
there is not output; if the directory is /tmp/test-project, it outputs
/tmp/test-project/test.php:1 CamelCaseClassName The class lower_case is not named in CamelCase.
Checks before submitting
- Be sure that there isn't already an issue about this. See: Issues list
- Be sure that there isn't already a pull request about this. See: Pull requests
- I have added every step to reproduce the bug.
- If possible I added relevant code examples.
- This issue is about 1 bug and nothing more.
- The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
That definitely misses a (^|[\\\\/])
prefix to match .git
only if it's on the beginning or after a directory separator.
Thanks the report and investigation to find the culprit 🙏
It was slightly more tricky than I though regarding how it's wired inside, but I think pdepend/pdepend#721 is a correct fix.