I'm facing the following issue with my Visual Code OSS extension phpcs 1.0.5 + Coder, whenever I open my Drupal Workspace:
phpcs: Uncaught Error: Call to undefined method DrupalPractice\Project::register() in ~/.config/composer/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1218
When I take a closer look, everything seems ok... is there something that I've missed?
$ pwd
~/.config/composer/vendor/squizlabs/php_codesniffer/src/Standards
$ ls -al
total 48
drwxr-xr-x 10 joe joe 4096 jan 13 17:11 .
drwxr-xr-x 11 joe joe 4096 apr 11 2019 ..
lrwxrwxrwx 1 joe joe 67 jan 13 17:11 Drupal -> ~/.config/composer/vendor/drupal/coder/coder_sniffer/Drupal
lrwxrwxrwx 1 joe joe 76 jan 13 17:11 DrupalPractice -> ~/.config/composer/vendor/drupal/coder/coder_sniffer/DrupalPractice/
drwxr-xr-x 5 joe joe 4096 apr 11 2019 Generic
drwxr-xr-x 4 joe joe 4096 apr 11 2019 MySource
drwxr-xr-x 5 joe joe 4096 apr 11 2019 PEAR
drwxr-xr-x 5 joe joe 4096 apr 11 2019 PSR1
drwxr-xr-x 5 joe joe 4096 apr 11 2019 PSR12
drwxr-xr-x 5 joe joe 4096 apr 11 2019 PSR2
drwxr-xr-x 5 joe joe 4096 apr 11 2019 Squiz
drwxr-xr-x 5 joe joe 4096 apr 11 2019 Zend
$ cat ~/.config/composer/vendor/drupal/coder/coder_sniffer/DrupalPractice/ruleset.xml
<?xml version="1.0"?>
<ruleset name="DrupalPractice">
<description>Drupal best practice checks</description>
<!-- All Drupal code files must be UTF-8 encoded and we treat them as such. -->
<arg name="encoding" value="utf-8"/>
<arg name="extensions" value="php,module,inc,install,test,profile,theme,yml"/>
<autoload>../Drupal/autoload.php</autoload>
<rule ref="Internal.NoCodeFound">
<!-- Empty files are fine, might be used for testing. -->
<exclude-pattern>*</exclude-pattern>
</rule>
<rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis.UndefinedVariable">
<!-- Do not run this sniff on template files. -->
<exclude-pattern>*.tpl.php</exclude-pattern>
</rule>
<!-- Ignore various version control directories. -->
<exclude-pattern>*/\.git/*</exclude-pattern>
<exclude-pattern>*/\.svn/*</exclude-pattern>
<exclude-pattern>*/\.hg/*</exclude-pattern>
<exclude-pattern>*/\.bzr/*</exclude-pattern>
</ruleset>
Comments
Comment #2
jazzitup commentedIt was just a configuration issue. I accidentally missed the following lines in order to properly register the coding standard:
Follow the manual: Installing Coder Sniffer