You are here

function _coder_error in Coder 5.2

Same name and namespace in other branches
  1. 5 coder.module \_coder_error()
  2. 6.2 coder.module \_coder_error()
  3. 6 coder.module \_coder_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_severity_name().

$lineno: Line number of error.

$line: Contents of line that triggered error.

$original: Deprecated.

3 calls to _coder_error()
do_coder_review_grep in ./coder.module
Search for a string.
do_coder_review_grep_invert in ./coder.module
Search for potentially missing string.
do_coder_review_regex in ./coder.module
Implements do_coder_review_* for regex match.

File

./coder.module, line 1307
Developer Module that assists with code review and version upgrade that supports a plug-in extensible hook system so contributed modules can define additional review standards.

Code

function _coder_error(&$results, $rule, $severity_name, $lineno = -1, $line = '', $original = '') {
  if (isset($rule['#warning_callback'])) {
    if (function_exists($rule['#warning_callback'])) {
      $warning = $rule['#warning_callback']();
    }
    else {

      // If this happens, there is an error in the rule definition.
      $warning = t('please <a href="@report">report</a> this !warning', array(
        '@report' => 'http://drupal.org/node/add/project_issue/coder/bug',
        '!warning' => $rule['#warning_callback'],
      ));
    }
  }
  else {
    $warning = t($rule['#warning']);
  }
  return _coder_error_msg($results, $warning, $severity_name, $lineno, $line);
}