Open alanmels opened 4 years ago
The above way was an attempt to get it working without Composer, however this might need to be resolved together with https://github.com/backdrop-contrib/coder_review/issues/3.
According to https://www.drupal.org/project/coder/issues/2809335 Codesniffer 3 is not supported, so I downgraded back to PHP_CodeSniffer-2.9.1:
sudo pear uninstall PHP_CodeSniffer
sudo pear install PHP_CodeSniffer-2.9.1
the same command phpcs --standard=Backdrop -e
is giving different error instead:
docker@cli:/var/www/docroot/modules$ phpcs --standard=Backdrop -e
Fatal error: Uncaught PHP_CodeSniffer_Exception: Referenced sniff "Generic.Formatting.SpaceAfterCast" does not exist in /usr/local/lib/php/PHP/CodeSniffer.php on line 1167
PHP_CodeSniffer_Exception: Referenced sniff "Generic.Formatting.SpaceAfterCast" does not exist in /usr/local/lib/php/PHP/CodeSniffer.php on line 1167
Call Stack:
0.0009 371528 1. {main}() /usr/local/bin/phpcs:0
0.0180 1391640 2. PHP_CodeSniffer_CLI->runphpcs() /usr/local/bin/phpcs:25
0.0186 1436496 3. PHP_CodeSniffer_CLI->process() /usr/local/lib/php/PHP/CodeSniffer/CLI.php:113
0.0292 1441448 4. PHP_CodeSniffer_CLI->explainStandard() /usr/local/lib/php/PHP/CodeSniffer/CLI.php:948
0.0294 1442152 5. PHP_CodeSniffer->process() /usr/local/lib/php/PHP/CodeSniffer/CLI.php:1203
0.0294 1442152 6. PHP_CodeSniffer->initStandard() /usr/local/lib/php/PHP/CodeSniffer.php:505
0.0298 1442616 7. PHP_CodeSniffer->processRuleset() /usr/local/lib/php/PHP/CodeSniffer.php:578
0.1026 1463072 8. PHP_CodeSniffer->_expandRulesetReference() /usr/local/lib/php/PHP/CodeSniffer.php:780
docker@cli:/var/www/docroot/modules$
I'm adding PHPCS code reviews for my Backdrop contrib projects using github actions. I was able to get results only by using PHP 5.6, and version 1.5.6 of PHPCS.
I ran into all the same problems you hit @alanmels and downgrading PHPCS to earlier versions was the answer each time.
I think Drupal 7 is on version 2 (to get PHP 7.3 support) and Drupal 8 is on version 3 now. See Related: https://www.drupal.org/project/coder/issues/2863898
Thank you, Jen, for your input. I think your finding needs to be reflected on Backdrop's UI so users avoid hitting the same problems.
I also think we should see if we can pull in the Drupal changes to get up to date :) I'll create a separate issue.
edit: https://github.com/backdrop-contrib/coder_review/issues/12 Update to a newer version of PHP_CodeSniffer
I just added the phpcs.phar with a direct download and was able to get it working with VSCode without any composer.
I am trying to get PHP_CodeSniffer working with Backdrop. So far I've got it installed on OS level by taking the following steps:
and now the both the
phpcs -i
andphpcbf -i
commands output:However, Backdrop is not picking up PHP_CodeSniffer and the status page still shows:
Also running simple
phpcs --standard=Backdrop -e
command outputs the error:Any further hints would be appreciated on how to get PHP_CodeSniffer working with Backdrop.