Magento uses the EQP Coding Standard tool for checking the coding standard of a module.https://github.com/magento/marketplace-eqp
Magento a tool used basically using the PHP_CodeSniffer tool.
If you want to run EQP Coding Standard on your local system, then follow the steps:
Go to your Magento root directory, and install this too using composer:
composer create-project --repository=https://repo.magento.com magento/marketplace-eqp
Magento-coding-standard
Then go to this tool directly using cd magento-coding-standard
run Composer update command composer
install which will update module dependency packages. Also, set config path specific PHP version set paths to php binary dir
vendor/bin/phpcs --config-set php7.0_path /path/to/your/php7
After that, you can use the below command for the checkout code start of your module from the Magento-coding-standard folder
php vendor/bin/phpcs /path/to/your/extension --standard=MEQP2
use MEQP2 for magento2 extension.
Example:
php vendor/bin/phpcs /var/www/html/MagentoProkect/app/code/DevAmitbera/CustomModule --standard=MEQP2 --extensions=php,phtml
Here I give the full path of my extension /var/www/html/MagentoProkect/app/code/DevAmitbera/CustomModule
4.1. If you use windows and face some path that must be translated related warning in the command line then try the below solution. Install Cygwin console from https://cygwin.com and then go to the Magento-coding-standard directory and run the below command.
vendor/bin/phpcs F:/xampp/htdocs/magento2/app/code/DevAmitbera/CustomModule --standard=MEQP2 --severity=10 --extensions=php,phtml
After That, I have run the code sniffer auto fixer command which is a basic code standards issue.
php vendor/bin/phpcbf /path/to/your/extension -extensions=php,phtml --standard=MEQP2
Example:
php vendor/bin/phpcbf /var/www/html/app/code/DevAmitbera/CustomModule --standard=MEQP2 --extensions=php,phtml
After re-run
Step 4 command for checking out the rest of errors which you need to fix yourself manually.