Download & Extend

False positive on switch { case: } statements

Project:Coder
Version:7.x-1.x-dev
Component:Review/Rules
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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.

Comments

#1

Status:active» needs review

Now I can... patch attached.

AttachmentSize
coder-583136.patch 1.29 KB

#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.

AttachmentSize
coder-583136.patch 1.13 KB

#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?

AttachmentSize
583136_coder_review_case.patch 1.18 KB

#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

Status:needs review» fixed

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

#7

Status:fixed» closed (fixed)

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