? .DS_Store
? 245471.coder.create-patch-files-wip.patch
Index: coder.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/coder.module,v
retrieving revision 1.88.2.59.2.18
diff -u -p -r1.88.2.59.2.18 coder.module
--- coder.module	9 Aug 2009 18:31:53 -0000	1.88.2.59.2.18
+++ coder.module	18 Dec 2009 21:09:52 -0000
@@ -1007,8 +1007,25 @@ function do_coder_reviews($coder_args) {
         $errors += $result;
       }
     }
+    
+    // Create a patch if this applies
+    // proof of concept only!
+    foreach ($errors as $error) {
+      if (isset($error['rule']['#patch'])) {
+        $newline = preg_replace('/' . $error['rule']['#patch'][0] . '/', $error['rule']['#patch'][1], $error['line']);
+        dsm($newline);
+        
+        $patch_log[] = $error['rule']['#warning'];
+      }
+    }
+    // Remove all the multiples from the log.
+    $patch_log = array_unique($patch_log);
+    dsm($patch_log);
+    // @todo: a nice touch would be to tell the user what the patch includes,
+    // since not all rules supply patching instructions
+    // this could also make CVS commit messages!
 
-    // Theme the error messages.
+      // Theme the error messages.
     foreach ($errors as $key => $error) {
       if (is_numeric($key)) {
         $results[$key] = theme('coder_warning_msg', $error);
Index: includes/coder_style.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/includes/Attic/coder_style.inc,v
retrieving revision 1.16.2.18.2.11
diff -u -p -r1.16.2.18.2.11 coder_style.inc
--- includes/coder_style.inc	18 Oct 2009 13:24:17 -0000	1.16.2.18.2.11
+++ includes/coder_style.inc	18 Dec 2009 21:09:53 -0000
@@ -28,6 +28,10 @@ function coder_style_reviews() {
       '#type' => 'regex',
       '#value' => '\s(if|elseif|while|foreach|switch|case|return|for|catch)\(',
       '#warning' => 'Control statements should have one space between the control keyword and opening parenthesis',
+      '#patch' => array(
+        '(\s(if|elseif|while|foreach|switch|case|return|for|catch))\(',
+        '$1 (',
+      ),
     ),
     array(
       '#type' => 'regex',
