Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpcbf slow execution with unfixable comment #3148

Open
alechko opened this issue Oct 29, 2020 · 0 comments
Open

phpcbf slow execution with unfixable comment #3148

alechko opened this issue Oct 29, 2020 · 0 comments

Comments

@alechko
Copy link

alechko commented Oct 29, 2020

Describe the bug
I've worked on a Drupal 7 project, and some files were taking 15+ seconds to run phpcbf. After some investigation I've narrowed the issue to a mis-formatted comment that is not fixable by phpcbf.

I've created 2 sample files (~1000 lines) with the same content except for one comment at the beginning of the test-slow.php file. The normal file takes <1sec to complete and the slow ~15sec.

When having phpcbf run on every file save (with vscode) the long execution time prevents the file from being saved causing serious delay in workflow.

Code sample
test-normal.php
test-slow.php

Custom ruleset
Drupal Code Standard

To reproduce
Steps to reproduce the behavior:

  1. Download the test files called test-normal.php and test-slow.php:
    1.1 curl -O https://gist.githubusercontent.com/alechko/394a97649460929a5347d8149f4e1f86/raw/276543c6864cf7b3af6e407188fd2a2989df0b76/test-normal.php
    1.2 curl -O https://gist.githubusercontent.com/alechko/394a97649460929a5347d8149f4e1f86/raw/276543c6864cf7b3af6e407188fd2a2989df0b76/test-slow.php
  2. Install Drupal CS
  3. Run phpcbf --standard=Drupal test-normal.php and phpcbf --standard=Drupal test-slow.php
phpcbf --standard=Drupal test-normal.php

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
/Users/alex/dev/php/test-normal.php        1      1052
----------------------------------------------------------------------
A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE
----------------------------------------------------------------------

Time: 886ms; Memory: 20MB




phpcbf --standard=Drupal test-slow.php

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
/Users/alex/dev/php/test-slow.php          FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 0 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Time: 15.21 secs; Memory: 22MB


Expected behavior
phpcbf execution time should not be delayed because of mis-formatted comment, the comments could be simply ignored.

Versions (please complete the following information):

  • OS: MacOS 10.15.7
  • PHP: 7.3.11
  • PHPCS: 3.5.6
  • Standard: Drupal

Note:

phpcs does not have the this issue, if you run phpcs --standard=Drupal on both files the execution time with be almost identical (<1 sec), only phpcbf has this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant