1

When I execute git commit, I get this error:

ERROR: the "PHPCompatibility" coding standard is not installed. The installed coding standards are MySource, PEAR, Zend, PSR2, PSR1, Squiz, PSR12, Drupal and DrupalPractice
Fix the PHPCompatibility error before commit please

Then I execute:

phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility

Executed git commit again; a new error appeared again:

ERROR: the "Drupal" coding standard is not installed. The installed coding standards are MySource, PEAR, Zend, PSR2, PSR1, Squiz and PSR12
Fix the Drupal Standard error before commit please

I executed the command again:

phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer

As a result, the original error appeared again:

the "PHPCompatibility" coding standard is not installed

What's wrong with my configuration?

enter image description here

enter image description here

enter image description here

River Zhao
  • 73
  • 2
  • 8

3 Answers3

0

I understand your pre-commit hook launches a linter that requires both standards to be installed simultaneously:

phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility,vendor/drupal/coder/coder_sniffer

Reference

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • Thanks a lot for your help, I executed the command: phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility,vendor/drupal/coder/coder_sniffer Refer to the link you gave to configure, but still report an error when executing git commit: ERROR: the "Drupal" coding standard is not installed. The installed coding standards are MySource, PEAR, Zend, PSR2, PSR1, Squiz and PSR12 Is it my configuration problem? Or the installation of drupal coder? Or is it a version issue? – River Zhao Jan 12 '22 at 03:09
  • What file contains the Drupal standard? – Álvaro González Jan 12 '22 at 07:17
0

I reinstalled php_codesniffer and drupal/coder, and executed the command:

 phpcs --config-set installed_paths /homeriverz/.config/composer/vendor/phpcompatibility/php-compatibility,/homeriverz/.config/composer/vendor/drupal/coder/coder_sniffer,/homeriverz/.config/composer/vendor/slevomat /coding-standard

will run normally

River Zhao
  • 73
  • 2
  • 8
0

In my case I have forgotten to install the package :-)

composer require phpcompatibility/php-compatibility --dev
TheodorosPloumis
  • 2,396
  • 1
  • 17
  • 31