False positive on switch { case: } statements
willmoy - September 21, 2009 - 02:37
| Project: | Coder |
| Version: | 7.x-1.x-dev |
| Component: | Review/Rules |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
I get—
Line 302: Functions should be called with no spaces between the function name and opening parentheses
<?php
case ($step > 3):
?>Fix: in coder_review_style.inc, add 'case' to the list of keywords in these two tests:
<?php
array(
'#type' => 'regex',
'#value' => '[\s\(](\w+)\s\(',
'#not' => '^(if|elseif|while|foreach|switch|return|for|list|catch)$',
'#warning' => 'Functions should be called with no spaces between the function name and opening parentheses',
),
array(
'#type' => 'regex',
'#value' => '\s(if|elseif|while|foreach|switch|return|for|catch)\(',
'#warning' => 'Control statements should have one space between the control keyword and opening parenthesis',
),
?>Sorry, can't patch atm. Hope this helps, though.

#1
Now I can... patch attached.
#2
The patch contains some AVG message at the bottom but seems to apply okay :)
#3
Thanks! For the sake of my OCD side, here's a clean patch.
#4
I got this when I applied the patch to a freshly checked out coder HEAD:
(Stripping trailing CRs from patch.)
patching file coder_review_style.inc
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 26 with fuzz 1.
I don't know if this is anything to worry about but I've created a patch in the coder root directory as per http://drupal.org/patch/create and attached it if you want to compare?
#5
Thanks for the review and the root dir tip. I've applied your patch to a clean checkout. It applies cleanly and the coder_review works as it should afterwards.
#6
Committed to 6.x-2.x and HEAD, thanks!
#7
Automatically closed -- issue fixed for 2 weeks with no activity.