summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--coder.module10
-rw-r--r--includes/coder_style.inc13
-rw-r--r--tests/coder_style.inc5
3 files changed, 16 insertions, 12 deletions
diff --git a/coder.module b/coder.module
index b752407..11fa054 100644
--- a/coder.module
+++ b/coder.module
@@ -1267,15 +1267,13 @@ function do_coder_review($coder_args, $review) {
*/
function do_coder_review_regex(&$coder_args, $review, $rule, $lines, &$results) {
if (isset($rule['#value'])) {
- $regex = '/'. $rule['#value'] .'/';
- if (!isset($rule['#case-sensitive'])) {
- $regex .= 'i';
- }
+ $regexflags = isset($rule['#case-sensitive']) ? '' : 'i';
+ $regex = '/'. $rule['#value'] .'/'. $regexflags;
$function_regex = isset($rule['#function']) ? '/'. $rule['#function'] .'/' : '';
$current_function = '';
$paren = 0;
- $not_regex = isset($rule['#not']) ? '/'. $rule['#not'] .'/i' : '';
- $never_regex = isset($rule['#never']) ? '/'. $rule['#never'] .'/i' : '';
+ $not_regex = isset($rule['#not']) ? '/'. $rule['#not'] .'/'. $regexflags : '';
+ $never_regex = isset($rule['#never']) ? '/'. $rule['#never'] .'/'. $regexflags : '';
foreach ($lines as $lineno => $line) {
// Some rules apply only within certain functions.
if ($function_regex) {
diff --git a/includes/coder_style.inc b/includes/coder_style.inc
index d32714d..2ccee15 100644
--- a/includes/coder_style.inc
+++ b/includes/coder_style.inc
@@ -114,12 +114,6 @@ function coder_style_reviews() {
),
array(
'#type' => 'regex',
- '#value' => '\[\s*[a-z][a-z0-9_]+\\s*]',
- '#warning' => 'use quotes around a string literal array index, this is not only a style issue, but a known performance problem',
- '#case-sensitive' => TRUE,
- ),
- array(
- '#type' => 'regex',
'#value' => '\s(if|elseif|while|foreach|switch|return|for|catch)\s*\(.*\) \s*{\s*[^\s]+',
'#warning' => 'The control statement should be on a separate line from the control conditional',
),
@@ -136,6 +130,13 @@ function coder_style_reviews() {
'#warning' => 'in most cases, replace the string function with the drupal_ equivalent string functions',
'#severity' => 'minor',
),
+ array(
+ '#type' => 'regex',
+ '#value' => '\[\s*[A-Za-z][A-Za-z0-9_]*\s*]',
+ '#not' => '\[\s*[A-Z][A-Z0-9_]*\s*]',
+ '#warning' => 'use quotes around a string literal array index, this is not only a style issue, but a known performance problem',
+ '#case-sensitive' => TRUE,
+ ),
);
$review = array(
'#title' => t('Drupal Coding Standards'),
diff --git a/tests/coder_style.inc b/tests/coder_style.inc
index 0dc7652..fb38177 100644
--- a/tests/coder_style.inc
+++ b/tests/coder_style.inc
@@ -10,6 +10,11 @@
* admin/coder/coder.
*/
+function coder_array_ticks() {
+ $some_array[FOO_BAR] = $baz; // This is ok.
+ $some_array[foo] = $baz; // This is not.
+}
+
function coder_test_tab() {
// Tab in comment - is this ok?
$var = 'tab in quote'; // Is this ok?