You are here

function _coder_review_error in Coder 7

Same name and namespace in other branches
  1. 7.2 coder_review/coder_review.common.inc \_coder_review_error()

Builds an error message based on the rule that failed and other information.

Parameters

$results: Results array variable to save errors to.

$rule: Rule array that triggered the error.

$severity_name: String severity of error as detected by _coder_review_severity_name().

$lineno: Line number of error.

$line: Contents of line that triggered error.

$original: Deprecated.

15 calls to _coder_review_error()
do_coder_review_grep in coder_review/coder_review.module
Search for a string.
do_coder_review_grep_invert in coder_review/coder_review.module
Search for potentially missing string.
do_coder_review_regex in coder_review/coder_review.module
Implements do_coder_review_* for regex match.
_coder_review_5x_callback in coder_review/includes/coder_review_5x.inc
Define the rule callbacks for 5.x, see do_coder_review_review_callback().
_coder_review_6x_callback in coder_review/includes/coder_review_6x.inc
Define the rule callbacks for 6.x, see do_coder_review_callback().

... See full list

File

coder_review/coder_review.module, line 1835

Code

function _coder_review_error(&$results, $rule, $severity_name, $lineno = -1, $line = '', $ignores = array()) {

  // Note: The use of the $key allows multiple errors on one line.
  // This assumes that no line of source has more than 10000 lines of code
  // and that we have fewer than 10000 errors.
  global $_coder_errno;

  // Skip warnings we've been told to ignore.
  if (is_array($ignores) && in_array($lineno, $ignores)) {
    $results['#stats']['ignored']++;
  }
  else {
    $key = ($lineno + 1) * 10000 + $_coder_errno++;
    $results[$key] = array(
      'rule' => $rule,
      'severity_name' => $severity_name,
      'lineno' => $lineno,
      'line' => $line,
    );
    $results['#stats'][$severity_name]++;
  }
}