You are here

function coder_performance_reviews in Coder 5

@file This include file implements coder functionality for Performance

Todo: The rules for this review are not yet complete.

File

includes/coder_performance.inc, line 9
This include file implements coder functionality for Performance

Code

function coder_performance_reviews() {
  $rules = array(
    array(
      '#type' => 'regex',
      '#value' => '[^\\w_](TRUE|FALSE|NULL)[^\\w_]',
      '#case-sensitive' => true,
      '#warning_callback' => '_coder_performance_case_variabletype_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '.*',
      // catch anything
      '#not' => '\\$',
      '#source' => 'doublequote',
      '#warning_callback' => '_coder_performance_double_quotes_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '\\$\\w+\\+\\+',
      '#warning_callback' => '_coder_performance_increment_warning',
    ),
    /* array( // I don't think this is true, I saw Rasmus explain this
         '#type' => 'regex',
         '#value' => 'for\s*\([^,]+;.+count',
         '#warning_callback' => '_coder_performance_for_count_warning',
       ), */
    array(
      '#type' => 'regex',
      '#value' => '\\(strlen\\(\\$\\w+\\) <=? \\d+\\)',
      '#warning_callback' => '_coder_performance_string_length_comparison_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '[^=] print',
      '#warning_callback' => '_coder_performance_print_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => 'in_array\\(\'\', \\$\\w+\\)',
      '#warning_callback' => '_coder_performance_in_array_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '(\\(|\\|\\||\\&\\&)\\s*(count|sizeof)\\(\\$\\w+\\)',
      '#warning_callback' => '_coder_performance_empty_warning',
    ),
  );
  $review = array(
    '#title' => 'Performance Optimization',
    '#link' => 'http://drupal.org/node/110128',
    '#rules' => $rules,
    '#severity' => 'minor',
    '#description' => t('under development, use with discretion'),
  );
  return array(
    'performance' => $review,
  );
}