-
-
Notifications
You must be signed in to change notification settings - Fork 89
Closed
Milestone
Description
Repost from squizlabs/PHP_CodeSniffer#3854:
Describe the bug
When
basepathis set in a custom ruleset AND PHPCS is subsequently run from within a subdirectory of the project AND theGitblamereport is requested, a fatal error happens.As far as I can see, this is due to the
$filenamewhich is being passed toGitblame::getBlameContent()not being the full path to the file, but the path with the basename stripped off.To reproduce
Steps to reproduce the behavior with PHPCS itself:
- Change into the
srcdirectory of the PHPCS project- Run
phpcs -psl . --report=gitblame- See the following error message displayed
PHP_CodeSniffer version 3.7.2 (stable) by Squiz (http://www.squiz.net) Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: chdir(): No such file or directory (errno 2) in path/to/src/Reports/Gitblame.php on line 72 in path/to/src/Runner.php:608 Stack trace: #0 [internal function]: PHP_CodeSniffer\Runner->handleErrors(2, 'chdir(): No suc...', '...', 72) #1 path/to/src/Reports/Gitblame.php(72): chdir('src') #2 path/to/src/Reports/VersionControl.php(43): PHP_CodeSniffer\Reports\Gitblame->getBlameContent('src\\Config.php') #3 path/to/src/Reporter.php(285): PHP_CodeSniffer\Reports\VersionControl->generateFileReport(Array, Object(PHP_CodeSniffer\Files\LocalFile), true, 150) #4 path/to/src/Runner.php(700): PHP_CodeSniffer\Reporter->cacheFileReport(Object(PHP_CodeSniffer\Files\LocalFile), Object(PHP_CodeSniffer\Config)) #5 path/to/src/Runner.php(438): PHP_CodeSniffer\Runner->processFile(Object(PHP_CodeSniffer\Files\LocalFile)) #6 path/to/src/Runner.php(116): PHP_CodeSniffer\Runner->run() #7 path/to/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS() #8 {main} thrown in path/to/src/Runner.php on line 608 Exit code is 255Expected behavior
No fatal error and the
git blamereport is displayed correctlyVersions (please complete the following information)
Operating System Windows 10 PHP version 8.2.7 (but not relevant) PHP_CodeSniffer version bleeding edge including the fix from squizlabs/PHP_CodeSniffer#3809 Standard PHPCS native phpcs.xml.distInstall type git clone Additional context
This issue is loosely related to squizlabs/PHP_CodeSniffer#3809.
PR upcoming.