PHPCSStandards / composer-installer

Composer installer for PHP_CodeSniffer coding standards
https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer
MIT License
552 stars 36 forks source link

Crash on installed path setup #81

Closed nterbogt closed 4 years ago

nterbogt commented 5 years ago

Problem/Motivation

phpcs is crashing due to invalid path setup.

Expected behaviour

I expect the correct path to be used.

Actual behaviour

nterbogt$ lando composer run-script install-codestandards
> Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer\Plugin::run
PHP CodeSniffer Config installed_paths set to ../../../web/modules/contrib/coder/coder_sniffer,CodeSniffer/Standards
nterbogt$ lando phpcs --standard=Drupal web/modules/contrib/new_relic_rpm
PHP Fatal error:  Uncaught UnexpectedValueException: DirectoryIterator::__construct(CodeSniffer/Standards): failed to open dir: No such file or directory in /app/vendor/squizlabs/php_codesniffer/CodeSniffer.php:2250
Stack trace:
#0 /app/vendor/squizlabs/php_codesniffer/CodeSniffer.php(2250): DirectoryIterator->__construct('CodeSniffer/Sta...')
#1 /app/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(1176): PHP_CodeSniffer::getInstalledStandards()
#2 /app/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(935): PHP_CodeSniffer_CLI->validateStandard(Array)
#3 /app/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php(113): PHP_CodeSniffer_CLI->process()
#4 /app/vendor/squizlabs/php_codesniffer/scripts/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()
#5 {main}
  thrown in /app/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 2250

Fatal error: Uncaught UnexpectedValueException: DirectoryIterator::__construct(CodeSniffer/Standards): failed to open dir: No such file or directory in /app/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 2250

UnexpectedValueException: DirectoryIterator::__construct(CodeSniffer/Standards): failed to open dir: No such file or directory in /app/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 2250

Call Stack:
    0.0033     441840   1. {main}() /app/vendor/squizlabs/php_codesniffer/scripts/phpcs:0
    0.0549    4253920   2. PHP_CodeSniffer_CLI->runphpcs() /app/vendor/squizlabs/php_codesniffer/scripts/phpcs:25
    0.0556    4363800   3. PHP_CodeSniffer_CLI->process() /app/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php:113
    0.0573    4368064   4. PHP_CodeSniffer_CLI->validateStandard() /app/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php:935
    0.0573    4368064   5. PHP_CodeSniffer::getInstalledStandards() /app/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php:1176
    0.0623    4386656   6. DirectoryIterator->__construct() /app/vendor/squizlabs/php_codesniffer/CodeSniffer.php:2250

Steps to reproduce

I think you set a large search path in here that includes the base standards directory from phpcs. "phpcodesniffer-search-depth": 6

Proposed changes

I believe it should exclude that directory because they are included by default?

Potherca commented 5 years ago

Hi! Before we investigate this further, could you post (a link to) the composer.json file that is used?

I would like to discern whether the issue lies with the installer, php_cs or elsewhere.

My concern is the path ../../../web/modules/contrib/coder/coder_sniffer,CodeSniffer/Standards.

Does this mean there is actually a directory called coder_sniffer,CodeSniffer?

Potherca commented 4 years ago

Closing this as "can't reproduce" for now. If this issue re-appears or more information is provided by @nterbogt that leads to a reproducable scenario, this issue can be re-opened.