squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.66k stars 1.48k forks source link

hangs forever while scanning CSS file #3598

Closed divinity76 closed 2 years ago

divinity76 commented 2 years ago

Describe the bug phpcs hangs forever while scanning the attached css file: fontAwesomeIE7.css.zip

Code sample see the attached css file (too large to comfortably inline.)

Custom ruleset no custom ruleset..

To reproduce Steps to reproduce the behavior:

  1. unzip the attached css file
  2. Run ./vendor/bin/phpcs -p fontAwesomeIE7.css -v
  3. check back 10 hours later, see that it's still working on that file, clearly frozen.. using 100% cpu of 1 core.
root@x2ratma:/home/hans/projects/phpstan# time ./vendor/bin/phpcs --runtime-set testVersion 8.1 -p fontAwesomeIE7.css -v
Registering sniffs in the PEAR standard... DONE (28 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /home/hans/projects/phpstan
Processing fontAwesomeIE7.css
14:31

^C
real    499m15.578s
user    447m50.731s
sys     1m13.497s

root@x2ratma:/home/hans/projects/phpstan# ls^C
root@x2ratma:/home/hans/projects/phpstan# time ./vendor/bin/phpcs -p fontAwesomeIE7.css -v
Registering sniffs in the PEAR standard... DONE (28 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /home/hans/projects/phpstan
Processing fontAwesomeIE7.css

Expected behavior not freeze

Versions (please complete the following information):

Additional context was initially discovered with PHPCompatibility and reported over at https://github.com/PHPCompatibility/PHPCompatibility/issues/1337

jrfnl commented 2 years ago

Additional info: the scope map recursion goes into an infinite loop on that file.

gsherwood commented 2 years ago

Support for non-PHP files is being removed from PHP_CodeSniffer and I'm not fixing any bugs for these file types. Please switch to another tool to check CSS standards.