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

willmoy - September 23, 2009 - 10:08
Status:active» needs review

Now I can... patch attached.

AttachmentSize
coder-583136.patch 1.29 KB

#2

matason - September 23, 2009 - 22:52

The patch contains some AVG message at the bottom but seems to apply okay :)

#3

willmoy - September 23, 2009 - 23:15

Thanks! For the sake of my OCD side, here's a clean patch.

AttachmentSize
coder-583136.patch 1.13 KB

#4

matason - September 24, 2009 - 21:05

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?

AttachmentSize
583136_coder_review_case.patch 1.18 KB

#5

willmoy - September 24, 2009 - 23:15

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

stella - October 18, 2009 - 13:27
Status:needs review» fixed

Committed to 6.x-2.x and HEAD, thanks!

#7

System Message - November 1, 2009 - 13:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.