Running Drupal code inspections via PHP Storm returns incorrect results When I run PHP Code Sniffer inspections in PHP Storm (latest version) for Drupal code using the latest Drupal coding standards (from the Coder module), I get incorrect results. Running the inspections manually on the command line seems to return the proper results. I don't know why.

Here's the output of running phpcs manually against this test file from the CAS module:

/Users/bosborne/.composer/vendor/bin/phpcs --standard=/Users/bosborne/.composer/vendor/drupal/coder/coder_sniffer/Drupal tests/src/Unit/Subscriber/CasSubscriberTest.php

FILE: ...ules/contrib/cas/tests/src/Unit/Subscriber/CasSubscriberTest.php
----------------------------------------------------------------------
FOUND 11 ERRORS AND 4 WARNINGS AFFECTING 15 LINES
----------------------------------------------------------------------
  16 | WARNING | [x] Unused use statement
  99 | ERROR   | [x] Expected "MockCondition" but found
     |         |     "MockCondition;" for @var tag in member variable
     |         |     comment
 131 | ERROR   | [x] Array indentation error, expected 6 spaces but
     |         |     found 8
 132 | ERROR   | [x] Array indentation error, expected 6 spaces but
     |         |     found 8
 133 | ERROR   | [x] Array indentation error, expected 6 spaces but
     |         |     found 8
 134 | ERROR   | [x] Array indentation error, expected 6 spaces but
     |         |     found 8
 135 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
 148 | ERROR   | [x] There should be no white space after an opening
     |         |     "["
 149 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
 162 | ERROR   | [x] There should be no white space after an opening
     |         |     "["
 163 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
 177 | ERROR   | [x] Object operator not indented correctly; expected
     |         |     6 spaces but found 35
 193 | ERROR   | [x] Object operator not indented correctly; expected
     |         |     6 spaces but found 28
 194 | ERROR   | [ ] If the line declaring an array spans longer than
     |         |     80 characters, each element should be broken
     |         |     into its own line
 564 | ERROR   | [x] Inline comments must start with a capital letter
----------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Lots of errors and warnings!

But when I configure my PHP Storm (latest version) to run the inspections on the same file, I get just two weak warnings, and the filedoc one it complains about is wrong (file docs are not required on namespaced files).



So something is out of wack here, but for the life of me I cannot figure out why PHP Storm is returning the wrong output. 

Environment info:


Using version 8.x-2.9 of the Coder module
Using version 2.7 of phpcs
Code Sniffer is setup in PHP Storm using the same exact path that I use when running the command manually (see config image below)
Inspections are setup in PHP Storm to use "Custom" inspections and I proide the path to the Drupal coding standards (the same path that I use when running it manually)






EDIT: I also filed an issue with PHP Storm directly: https://youtrack.jetbrains.com/issue/WI-34029
OK - Embarrassingly enough, this was indeed "user error". The path to the coding standard that PHP Storm was using was indeed slightly different than the path I thought it was using. The paths were quite similar so I didn't catch it during my own reviews.

What helped is that you can configure PHP Storm to output the exact command it runs in the debug log by doing the following: Open Help > Debug Log Settings and add there com.jetbrains.php. Then run the inspection and look at the debug log.