Add `phpcs` command
Is your feature request related to a problem? Please describe
As a module maintainer I want an easy way to lint Drupal coding standards.
Describe the solution you'd like
- [ ] Add PHPCS and setup coding standards
- [ ] Add DDev
phpcscommand
Describe alternatives you've considered
Additional context
It appears PHPCS is already installed and configured in the Gitpod environment, but not inside of the DDev environment.
The following command can be run:
./vendor/bin/phpcs -s --standard=Drupal,DrupalPractice --extensions=module,php,install,inc,test,info.yml,js repos/[module]
An example command for DDev: .ddev/comands/web/phpcs
#!/bin/bash
## Description: Run PHP_CodeSniffer
## Usage: phpcs [flags] [args]
## Example: "ddev phpcs contrib/module/druxt"
cd web
php ../vendor/bin/phpcs -s --standard=Drupal,DrupalPractice --extensions=module,php,install,inc,test,info.yml,js $@
If it's in vendor/bin... that means it's in the code, and also inside the container. So not understanding what you're saying about not being able to run it inside the container.
The issue is the Drupal coding standards aren't installed in DDev.
ERROR: the "Drupal" coding standard is not installed. The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz and Zend
But they are installed in the Gitpod environment.
I also haven't confirmed if PHPCS is generally available, or if it's the specific environment or PR that I'm starting from
You wouldn't install the Drupal coding standards in "ddev" would you? You'd install them in the project?
There are good reasons to install these things globally where we're trying to leave the code "as is", like when testing a vanilla drupal install.
Here's how to add phpcs and coder globally, https://stackoverflow.com/questions/61870801/add-global-phpcs-and-drupal-coder-to-ddev-in-custom-dockerfile
We looked into PHPCS while getting the recommended VSCode extensions for Drupal development - https://github.com/shaal/DrupalPod/pull/30