Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #20482 Scope indent sniff can get into infinite loop when processing a parse error
Submitted: 2015-01-12 01:35 UTC
From: sourc7 Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 2.1.0)
PHP Version: 5.6.4 OS: Windows 8.1
Roadmaps: (Not assigned)    
Subscription  


 [2015-01-12 01:35 UTC] sourc7 (Irvan Kurniawan)
Description: ------------ Hi, I'm upgrading PHP_CodeSniffer from 1.5.6 to 2.1.0 (latest) but when I analyze php file containing echo "". It's not output the result but just waiting with high cpu usage. But after I removing the PHP_CodeSniffer 2.10 then Re-installing the 1.5.6 the problem is solved Test script: --------------- <?php echo "" Expected result: ---------------- FOUND 2 ERROR(S) AFFECTING 2 LINE(S) -------------------------------------------------------------------------------- 1 | ERROR | End of line character is invalid; expected "\n" but found "\r\n" 2 | ERROR | Missing file doc comment -------------------------------------------------------------------------------- UPGRADE TO PHP_CODESNIFFER 2.0 TO FIX ERRORS AUTOMATICALLY -------------------------------------------------------------------------------- Actual result: -------------- None with High CPU usage

Comments

 [2015-01-12 08:22 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Verified -Assigned To: +Assigned To: squiz
The Generic.WhiteSpace.ScopeIndent sniff seems to be getting caught out by that parse errors. I'll take a look into it now.
 [2015-01-12 08:35 UTC] squiz (Greg Sherwood)
-Summary: PHP_CodeSniffer Won't Analyze and High CPU Usage +Summary: Scope indent sniff can get into infinite loop due wen processing parse error
 [2015-01-12 08:36 UTC] squiz (Greg Sherwood)
-Summary: Scope indent sniff can get into infinite loop due wen processing parse error +Summary: Scope indent sniff can get into infinite loop when processing a parse error
 [2015-01-12 08:37 UTC] squiz (Greg Sherwood)
-Status: Verified +Status: Closed
I've committed a fix for this issue here: https://github.com/squizlabs/PHP_CodeSniffer/commit/850eb7d82eefb20bbb31e8caea6 8569f4d4d1acf It should stop the scope indent sniff failing for related errors as well.