vijaycs85 / drupal-quality-checker

51 stars 37 forks source link

Drupal coding standard not installed #23

Closed felmab closed 4 years ago

felmab commented 4 years ago

I installed Drupal Code Quality Checker with Composer: composer require --dev vijaycs85/drupal-quality-checker:1.2.1 (I cannot install the latest version due to conflicts with dependencies already installed).

When I commit, I get the following message :

ERROR: the "Drupal" coding standard is not installed. The installed coding standards are MySource, PEAR, PSR12, Squiz, Zend, PSR1 and PSR2

How can I force to register the Drupal coding standard?

Here is my grumphp.yml file:

parameters:
  ascii:
    failed: vendor/vijaycs85/drupal-quality-checker/resources/ascii/grumpy.txt
    succeeded: vendor/vijaycs85/drupal-quality-checker/resources/ascii/happy.txt
  git_dir: .
  bin_dir: vendor/bin
  git_hook_variables:
      VAGRANT_PROJECT_DIR: /var/www/html
      EXEC_GRUMPHP_COMMAND: ddev exec
  tasks:
    phplint: ~
    yamllint: ~
    composer: ~
    composer_normalize: ~
    jsonlint: ~
    phpcs:
      standard: Drupal
      ignore_patterns:
        - .github
        - .gitlab
        - bower_components
        - node_modules
        - vendor
      triggered_by:
        - php
        - module
        - inc
        - install
        - test
        - profile
        - theme
        - css
        - info
        - txt
        - md
felmab commented 4 years ago

I had to replace by

standard: web/modules/contrib/coder/coder_sniffer/Drupal/

not sure why.

Judapriest commented 4 years ago

Seems to me that you are missing those two package :

  1. "dealerdirect/phpcodesniffer-composer-installer": "*",
  2. "drupal/coder": "^8.3",

drupal/coder install is for the drupal standard for phpcs dealerdirect/phpcodesniffer-composer-installer is for helping phpcs detect the drupal standard from drupal/coder

felmab commented 4 years ago

Thanks @Judapriest, composer show reports dealerdirect/phpcodesniffer-composer-installer v0.6.2 and drupal/coder 8.3.9 are installed. Of course, drupal/coder is installed in web/modules/contrib like all Drupal modules. The "Drupal" standard is installed, I believe it is not properly referenced. I guess somehow it has to be registered and don't know how to force registration.

felmab commented 4 years ago

Of course, drupal/coder is installed in web/modules/contrib like all Drupal modules.

On another install it is in vendor/drupal/coder, this might be part of the problem.

felmab commented 4 years ago

On the faulty installation:

name     : drupal/coder
descrip. : 
keywords : 
versions : * 8.3.9
type     : drupal-module
license  : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved) https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText
homepage : https://www.drupal.org/project/coder
source   : [git] https://git.drupalcode.org/project/coder.git 8.3.9
dist     : [zip] https://ftp.drupal.org/files/projects/coder-8.3.9.zip 8.3.9
path     : /path/to/installation/project/web/modules/contrib/coder
names    : drupal/coder

support
source : https://git.drupalcode.org/project/coder

requires
drupal/core ~8.0

requires (dev)
drupal/rules *

"Type" could be wrong, hence the installation path.

On a previous installation:

name     : drupal/coder
descrip. : Coder is a library to review Drupal code.
keywords : code review, phpcs, standards
versions : * 8.3.8
type     : phpcodesniffer-standard
license  : GNU General Public License v2.0 or later (GPL-2.0+) (OSI approved) https://spdx.org/licenses/GPL-2.0+.html#licenseText
homepage : https://www.drupal.org/project/coder
source   : [git] https://git.drupalcode.org/project/coder.git e53e75b45842a5d2b454b08c318a17f57339e60e
dist     : []  
path     : /path/to/installation/project/vendor/drupal/coder
names    : drupal/coder

autoload
psr-4
Drupal\ => coder_sniffer/Drupal/
DrupalPractice\ => coder_sniffer/DrupalPractice/

requires
ext-mbstring *
php >=7.0.8
squizlabs/php_codesniffer ^3.5.4
symfony/yaml >=2.0.5

requires (dev)
phpstan/phpstan ^0.12.5
phpunit/phpunit ^6.0 || ^7.0
felmab commented 4 years ago

"Type" could be wrong, hence the installation path.

Upstream looks good, though.

felmab commented 4 years ago

This appears to be a Composer issue.

Possible workarounds for the time being: