Coder - Drupal 8 Module
In order to use Coder module, you would need to Install Coder Sniffer on your machine.
A detailed steps can be found at https://www.drupal.org/node/1419988 for Installing Coder Sniffer. Please follow the steps and you will have it ready to use.
A detailed information about Command Line Usage can be found at https://www.drupal.org/node/1587138
Commands For checking Coding Standards in Drupal 8
- For Drupal
phpcs --standard=/home/username/.composer/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /path/to/drupal/module/
phpcs --standard=/home/username/.composer/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /var/www/html/drupal-8.2.2/modules/custom/guestbooks
- For DrupalPractice
phpcs --standard=/home/username/.composer/vendor/drupal/coder/coder_sniffer/DrupalPractice/ruleset.xml --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /path/to/drupal/module/
phpcs --standard=/home/username/.composer/vendor/drupal/coder/coder_sniffer/DrupalPractice/ruleset.xml --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /var/www/html/drupal-8.2.2/modules/custom/guestbooks
- For For Automatically fix Coding Standards
phpcbf --standard=/home/username/.composer/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /file/to/drupal/example_module
phpcbf --standard=/home/username/.composer/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /var/www/html/drupal-8.2.2/modules/custom/guestbooks
HOWEVER, AFTER setting up ALIASES for above commands in /home/.bashrc file, the new commands would be
$ drupalcs sites/all/modules/mymodule - To check Drupal Coding standards
$ drupalpcs sites/all/modules/mymodule - To check Drupal Best Practices
$ drupalcbf sites/all/modules/mymodule - To Automatically fix coding standards
Add new comment