You are here

function theme_drush_coder_review_warning in Coder 7

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

Theme warning message, including source snippet.

1 call to theme_drush_coder_review_warning()
theme_coder_review_warning in coder_review/coder_review.module
Format a coder_review warning to be included in results.

File

coder_review/coder_review.drush.inc, line 258
Command line utility for coder_review.

Code

function theme_drush_coder_review_warning($variables) {
  $warning = $variables['warning'];
  $severity_name = $variables['severity_name'];
  $lineno = isset($variables['lineno']) ? $variables['lineno'] : 0;
  $line = isset($variables['line']) ? $variables['line'] : '';
  $checkstyle_levels = array(
    'minor' => 'info',
    'normal' => 'warning',
    'critical' => 'error',
  );
  if (_coder_review_drush_is_option('xml') || _coder_review_drush_is_option('checkstyle')) {
    $attr = array(
      'line' => $lineno,
      'column' => 0,
      'severity' => $severity_name,
      'message' => $warning,
      'source' => $line,
    );
    if (_coder_review_drush_is_option('checkstyle')) {
      $attr['severity'] = $checkstyle_levels[$severity_name];
    }
    $output = '<error ' . drupal_attributes($attr) . ' />';
    return $output;
  }
  else {
    $output = $lineno ? '+' . $lineno . ': ' : '';
    $output .= '[' . $severity_name . '] ';
    $output .= is_array($warning) ? $warning['#warning'] : $warning;
    return _coder_review_drush_output($output);
  }
}