Skip to content

Let's get PHP_CodeSniffer working with Backdrop #10

@alanmels

Description

@alanmels

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:

sudo pear channel-update pear.php.net
sudo pear install PHP_CodeSniffer
sudo ln -sv /var/www/docroot/modules/coder_review/coder_sniffer/Backdrop $(pear config-get php_dir)/PHP/CodeSniffer/Standards
sudo phpcs --config-set installed_paths /var/www/docroot/modules/coder_review/coder_sniffer
sudo phpcbf --config-set installed_paths /var/www/docroot/modules/coder_review/coder_sniffer

and now the both the phpcs -i and phpcbf -i commands output:

The installed coding standards are Squiz, Zend, MySource, PSR1, PEAR, PSR2, PSR12 and Backdrop

However, Backdrop is not picking up PHP_CodeSniffer and the status page still shows:

Coder Review 
PHP_CodeSniffer not installed. 
Coder review uses PHP_CodeSniffer to perform better code review checks; Code_Sniffer is not a requirement, but it is helpful. Use "drush install-php-code-sniffer" to help install.

Also running simple phpcs --standard=Backdrop -e command outputs the error:

docker@cli:/var/www/docroot/modules$ phpcs --standard=Backdrop -e

Fatal error: Class 'Generic_Sniffs_Strings_UnnecessaryStringConcatSniff' not found in /var/www/docroot/modules/coder_review/coder_sniffer/Backdrop/Sniffs/Strings/UnnecessaryStringConcatSniff.php on line 30

Call Stack:
    0.0011     371072   1. {main}() /usr/local/bin/phpcs:0
    0.0045     531672   2. PHP_CodeSniffer\Runner->runPHPCS() /usr/local/bin/phpcs:18
    0.0232     901376   3. PHP_CodeSniffer\Runner->init() /usr/local/lib/php/PHP/CodeSniffer/src/Runner.php:70
    0.0309    1138136   4. PHP_CodeSniffer\Ruleset->__construct() /usr/local/lib/php/PHP/CodeSniffer/src/Runner.php:332
    0.1454    1187120   5. PHP_CodeSniffer\Ruleset->registerSniffs() /usr/local/lib/php/PHP/CodeSniffer/src/Ruleset.php:217
    0.1455    1187120   6. PHP_CodeSniffer\Autoload::loadFile() /usr/local/lib/php/PHP/CodeSniffer/src/Ruleset.php:1156
    0.1458    1214456   7. include('/var/www/docroot/modules/coder_review/coder_sniffer/Backdrop/Sniffs/Strings/UnnecessaryStringConcatSniff.php') /usr/local/lib/php/PHP/CodeSniffer/autoload.php:167

docker@cli:/var/www/docroot/modules$ 

Any further hints would be appreciated on how to get PHP_CodeSniffer working with Backdrop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions