composer-installer: Incorrect relative paths for WPCS
Problem/Motivation
Possibly related to #32.
With the following in my composer:
"dealerdirect/phpcodesniffer-composer-installer": "^0.4",
"wimg/php-compatibility": "dev-feature/prevent-conflicts-with-other-standards",
"wp-coding-standards/wpcs": "dev-develop"
the installed_paths phpcs config value is wrong.
Composer resolves this as using PHPCS 3.0.2, and the relative branches of WPCS and PHPCompatibility, both of which support PHPCS 3.*.
Expected behaviour
I expect the paths to be correct. With 0.3 of this plugin. I get:
<?php
$phpCodeSnifferConfig = array (
'installed_paths' => '/Users/gary/Local Sites/incipio/app/public/wp-content/themes/incipio/vendor/wp-coding-standards/wpcs,/Users/gary/Local Sites/incipio/app/public/wp-content/themes/incipio/vendor/wimg/php-compatibility',
)
?>
phpcs -i shows all of the standards correctly available, and phpcs runs correctly against the phpcs.xml.dist in my project.
Actual behaviour
With 0.4 of the plugin, I get:
<?php
$phpCodeSnifferConfig = array (
'installed_paths' => '../../wp-coding-standards/wpcs/WordPress/,../../wp-coding-standards/wpcs/WordPress-Core/,../../wp-coding-standards/wpcs/WordPress-Docs/,../../wp-coding-standards/wpcs/WordPress-Extra/,../../wp-coding-standards/wpcs/WordPress-VIP/,../../wimg/php-compatibility/PHPCompatibility/',
)
?>
phpcs -i still does show the right standards are available, but, phpcs does not run correctly. Depending on the first called ruleset in phpcs.xml.dist, I get an error the form:
ERROR: Referenced sniff "WordPress" does not exist
This also happens if phpcs . --standard=WordPress is called.
Interestingly, calling phpcs . --standard=WordPress-Core does appear to run.
I’m not sure where the issue lies exactly, but @jrfnl says:
PHPCS 3.x is supposed to support standards as a top-level folder (as in how PHPCompatibility used to be layed out and how DealerDirect registered the paths now), but that looks to be buggy based on your findings.
I can run some tests with that and will report my finding to PHPCS, but basically as long as the
installed_pathsare registered in the PHPCS 2.x way (which is also still the recommendation for PHPCS 3.x), things should be fine.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (17 by maintainers)
Commits related to this issue
- Explicitly recommend v0.3.x of the DealerDirect Composer plugin Version 0.4.x of the DealerDirect Composer plugin registers each standard individually as if they were root-directory standards, not a ... — committed to WordPress/WordPress-Coding-Standards by jrfnl 7 years ago
- Fixes #33. Changes the way the installed_paths are set. Changes the behavior of registering installed_paths in PHP_CodeSniffer 3.x. It will now work in the same way as was required for PHP_CodeSniffe... — committed to PHPCSStandards/composer-installer by frenck 7 years ago
- Merge pull request #34 from DealerDirect/hotfix/change-installed-paths-behavior Fixes #33. Changes the way the installed_paths are set. — committed to PHPCSStandards/composer-installer by frenck 7 years ago
- Explicitly recommend v0.4.1+ of the DealerDirect Composer plugin Version 0.4.0 of the DealerDirect Composer plugin registers each standard individually as if they were root-directory standards, not a... — committed to WordPress/WordPress-Coding-Standards by jrfnl 7 years ago
- Composer: make the version requirement for the Composer PHPCS plugin more flexible, take two Further iteration on earlier fix, now no longer using unbound restraints. Note: Version `0.4.0` is exclud... — committed to PHPCSStandards/PHPCSDevTools by jrfnl 5 years ago
- Composer: make the version requirement for the Composer PHPCS plugin more flexible, take two Further iteration on earlier fix, now no longer using unbound restraints. Note: Version `0.4.0` is exclud... — committed to PHPCSStandards/PHPCSDevTools by jrfnl 5 years ago
- Composer: make the version requirement for the Composer PHPCS plugin more flexible ... to prevent conflicts with projects, be it external standards or end-user projects, which require the plugin them... — committed to PHPCSStandards/PHPCSUtils by jrfnl 5 years ago
- Composer: make the version requirement for the Composer PHPCS plugin more flexible ... to prevent conflicts with projects, be it external standards or end-user projects, which require the plugin them... — committed to PHPCSStandards/PHPCSUtils by jrfnl 5 years ago
@frenck
0.4.1seems to work well. Having added another code standard (ObjectCalisethenics), I now correctly getCodeSniffer.confas:Thank you 😃
@jrfnl I have created a working solution on my laptop at this moment. I’ve tested it extensively, including the case mentioned by @GaryJones.
I will do some documentation and some more (paranoia) testing and get back to you guys as soon as possible.
Hi @GaryJones & @jrfnl,
The issue indeed seems an error / unexpected behavior. I will look into this today and tomorrow trying to reproduce and fix what needs fixing.
…/Frenck