How to:
Check Drupal coding standards
Check Drupal best practices
Automatically fix coding standards
Question
1. Install coder
drush dl coder
composer global require drupal/coder
sudo ln -s ~/.composer/vendor/bin/phpcs /usr/local/bin
sudo ln -s ~/.composer/vendor/bin/phpcbf /usr/local/bin
phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer
2.Run
Check Drupal coding standards
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme /path/your_module
Check Drupal best practices
phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme /path/your_module
Automatically fix coding standards
phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme /path/your_module
Comments