cakephp / cakephp-codesniffer

CakePHP Code Sniffer
http://cakephp.org
MIT License
238 stars 84 forks source link

Files are not queued by phpcs when using this standard #370

Closed rochamarcelo closed 1 year ago

rochamarcelo commented 1 year ago

When I use the CakePHP standard (tag 5.0.1) no files are queued to be processed with phpcs, the issue does happens with other standard (tested with PSR.

Docker Image: webdevops/php-nginx:8.1 PHP Version: PHP 8.1.13 (cli) (built: Dec 6 2022 06:07:35) (NTS) PHP_CodeSniffer Version: PHP_CodeSniffer version 3.7.1 (stable) by Squiz (http://www.squiz.net) CakePHP Codesniffer: 5.0.1

Using CakePHP standard (no files added)

vendor/bin/phpcs -p -v --standard=CakePHP  src/Exception/
Registering sniffs in the CakePHP standard... DONE (142 sniffs registered)
Creating file list... DONE (0 files in queue)
Time: 53ms; Memory: 10MB

Using PSR2 standard (9 files added)

vendor/bin/phpcs -p -v --standard=PSR2  src/Exception/
Registering sniffs in the PSR2 standard... DONE (43 sniffs registered)
Creating file list... DONE (9 files in queue)
.........
markstory commented 1 year ago

Do you have a way to reproduce this? I tried to reproduce this with the cake-app skeleton, and wasn't able to.

ᐉ composer up
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 1 install, 15 updates, 2 removals
  - Removing jdorn/sql-formatter (v1.2.17)
  - Removing phpstan/phpstan (1.9.7)
  - Upgrading cakephp/bake (2.8.2 => 3.x-dev 06eff77)
  - Upgrading cakephp/cakephp (4.4.10 => 5.x-dev 78aadc7)
  - Upgrading cakephp/cakephp-codesniffer (4.6.0 => 5.0.1)
  - Upgrading cakephp/chronos (2.3.2 => 3.x-dev 6d1d6fc)
  - Upgrading cakephp/debug_kit (4.9.2 => 5.x-dev d08cb48)
  - Upgrading cakephp/migrations (3.7.1 => 4.x-dev a4f59c5)
  - Upgrading cakephp/plugin-installer (1.3.1 => 2.0.0-beta1)
  - Upgrading cakephp/twig-view (1.3.0 => 2.x-dev 9911e23)
  - Upgrading composer/ca-bundle (1.3.4 => 1.3.5)
  - Upgrading dealerdirect/phpcodesniffer-composer-installer (v0.7.2 => v1.0.0)
  - Locking doctrine/sql-formatter (1.1.3)
  - Upgrading mobiledetect/mobiledetectlib (2.8.41 => 3.74.0)
  - Upgrading psr/log (2.0.0 => 3.0.0)
  - Upgrading psr/simple-cache (2.0.0 => 3.0.0)
  - Upgrading robmorgan/phinx (0.13.4 => 1.x-dev 8a6ce3f)
  - Upgrading slevomat/coding-standard (8.7.1 => 8.8.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 15 updates, 2 removals
  - Syncing cakephp/cakephp (5.x-dev 78aadc7) into cache
  - Downloading cakephp/bake (3.x-dev 06eff77)
  - Syncing cakephp/debug_kit (5.x-dev d08cb48) into cache
  - Syncing cakephp/migrations (4.x-dev a4f59c5) into cache
  - Removing phpstan/phpstan (1.9.7)
  - Removing jdorn/sql-formatter (v1.2.17)
  - Upgrading cakephp/plugin-installer (1.3.1 => 2.0.0-beta1): Extracting archive
  - Upgrading dealerdirect/phpcodesniffer-composer-installer (v0.7.2 => v1.0.0): Extracting archive
  - Upgrading psr/simple-cache (2.0.0 => 3.0.0): Extracting archive
  - Upgrading psr/log (2.0.0 => 3.0.0): Extracting archive
  - Upgrading composer/ca-bundle (1.3.4 => 1.3.5): Extracting archive
  - Upgrading cakephp/chronos (2.3.2 => 3.x-dev 6d1d6fc): Extracting archive
  - Upgrading cakephp/cakephp (4.4.10 => 5.x-dev 78aadc7): Checking out 78aadc7f1b from cache
  - Upgrading cakephp/twig-view (1.3.0 => 2.x-dev 9911e23): Extracting archive
  - Upgrading cakephp/bake (2.8.2 => 3.x-dev 06eff77): Extracting archive
  - Upgrading slevomat/coding-standard (8.7.1 => 8.8.0): Extracting archive
  - Upgrading cakephp/cakephp-codesniffer (4.6.0 => 5.0.1): Extracting archive
  - Installing doctrine/sql-formatter (1.1.3): Extracting archive
  - Upgrading cakephp/debug_kit (4.9.2 => 5.x-dev d08cb48): Checking out d08cb48b0d from cache
  - Upgrading robmorgan/phinx (0.13.4 => 1.x-dev 8a6ce3f): Extracting archive
  - Upgrading cakephp/migrations (3.7.1 => 4.x-dev a4f59c5): Checking out a4f59c546c from cache
  - Upgrading mobiledetect/mobiledetectlib (2.8.41 => 3.74.0): Extracting archive
Generating autoload files
57 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
ᐉ vendor/bin/phpcs -p -v --standard=CakePHP src/
Registering sniffs in the CakePHP standard... DONE (142 sniffs registered)
Creating file list... DONE (14 files in queue)
Changing into directory /home/mark/code/cake-app/src/Model/Entity
Processing Product.php [PHP => 162 tokens in 33 lines]... DONE in 11ms (1 errors, 0 warnings)
Changing into directory /home/mark/code/cake-app/src/Model/Table
Processing ProductsTable.php [PHP => 397 tokens in 70 lines]... DONE in 9ms (3 errors, 0 warnings)
Changing into directory /home/mark/code/cake-app/src/Controller
Processing AppController.php [PHP => 219 tokens in 52 lines]... DONE in 4ms (0 errors, 0 warnings)
Processing ErrorController.php [PHP => 334 tokens in 70 lines]... DONE in 7ms (3 errors, 0 warnings)
Processing DownloadController.php [PHP => 175 tokens in 29 lines]... DONE in 4ms (7 errors, 0 warnings)
Processing PagesController.php [PHP => 491 tokens in 73 lines]... DONE in 8ms (0 errors, 0 warnings)
Changing into directory /home/mark/code/cake-app/src/Command
Processing BugCommand.php [PHP => 109 tokens in 21 lines]... DONE in 3ms (2 errors, 0 warnings)
Changing into directory /home/mark/code/cake-app/src
Processing Application.php [PHP => 698 tokens in 136 lines]... DONE in 13ms (0 errors, 0 warnings)
Changing into directory /home/mark/code/cake-app/src/View
Processing AppView.php [PHP => 182 tokens in 41 lines]... DONE in 3ms (0 errors, 0 warnings)
Processing AjaxView.php [PHP => 223 tokens in 46 lines]... DONE in 3ms (0 errors, 0 warnings)
Changing into directory /home/mark/code/cake-app/src/View/Helper
Processing TestHelper.php [PHP => 94 tokens in 21 lines]... DONE in 2ms (4 errors, 0 warnings)
Changing into directory /home/mark/code/cake-app/src/Console
Processing Installer.php [PHP => 1739 tokens in 250 lines]... DONE in 29ms (0 errors, 0 warnings)
Changing into directory /home/mark/code/cake-app/src/Error
Processing MissingWidgetException.php [PHP => 38 tokens in 9 lines]... DONE in 1ms (2 errors, 0 warnings)
Processing CustomExceptionRenderer.php [PHP => 73 tokens in 14 lines]... DONE in 2ms (4 errors, 0 warnings)
dereuromark commented 1 year ago

Very likely this file is missing: https://github.com/cakephp/app/blob/de208ea53390b9e392b30254b8d835e18260c5d6/phpcs.xml

rochamarcelo commented 1 year ago

Today I understood why no files were processed. The plugin was located at /app/vendor/tmp/plugincake5 and CakePHP ruleset.xml exclude all from tmp folder. Moved the plugin to /app/vendor/plugincake5 and it worked.

The tmp folder was just a easy way to code|test the plugins inside vendor folder, I can remove the tmp folder.

vendor/bin/phpcs -p -v --standard=CakePHP  src/Exception/
Registering sniffs in the CakePHP standard... DONE (142 sniffs registered)
Creating file list... DONE (9 files in queue)
Changing into directory /app/vendor/plugincake5/src/Exception

Thank you for your time.