You are here

function _coder_review_error in Coder 7.2

Same name and namespace in other branches
  1. 7 coder_review/coder_review.module \_coder_review_error()

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

Parameters

array $results: A Results array variable to save errors to, passed by reference.

array $rule: A Rule array that triggered the error.

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

int $lineno: (optional) The line number on which the error was detected. Defaults to negative one.

string $line: (optional) The content of the line that triggered the error. Defaults to an empty string.

array $ignores: (optional) Any warnings to ignore. Defaults to an empty array.

See also

_coder_review_severity_name()

17 calls to _coder_review_error()
do_coder_review_grep in coder_review/coder_review.common.inc
Performs a 'grep' type of coder_review.
do_coder_review_grep_invert in coder_review/coder_review.common.inc
Performs a 'grep_invert' type of coder_review.
do_coder_review_regex in coder_review/coder_review.common.inc
Performs a 'regex' type of coder_review.
_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.common.inc, line 1108
Common functions used by both the drush and form interfaces.

Code

function _coder_review_error(array &$results, array $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 (_coder_review_ignore($rule, $lineno, $ignores)) {
    ++$results['#stats']['ignored'];
  }
  else {
    $key = ($lineno + 1) * 10000 + $_coder_errno++;
    $results[$key] = array(
      'rule' => $rule,
      'severity_name' => $severity_name,
      'review_name' => $rule['#review_name'],
      'rule_name' => $rule['#rule_name'],
      'lineno' => $lineno,
      'line' => $line,
    );
    ++$results['#stats'][$severity_name];
  }
}