You are here

function theme_drush_coder_review_warning in Coder 7.2

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

Returns warning message, including source snippet, in format for drush use.

Parameters

array $variables: An associative array with the following keys:

  • lineno:
  • severity_name:
  • warning:
  • line:
  • rule_name:
  • review_name:
1 call to theme_drush_coder_review_warning()
theme_coder_review_warning in coder_review/coder_review.common.inc
Returns HTML for a coder_review warning to be included in results.

File

coder_review/coder_review.drush.inc, line 624
Command line utility support for Coder_review module.

Code

function theme_drush_coder_review_warning(array $variables) {

  // Supply default theme variables.
  $variables += array(
    'lineno' => 0,
    'line' => '',
    'warning' => dt('Unknown warning (drush)'),
  );

  // Return warning as XML.
  if (drush_get_option('xml') || drush_get_option('checkstyle')) {
    $attr = array(
      'line' => $variables['lineno'],
      'column' => 0,
      'severity' => $variables['severity_name'],
      'message' => $variables['warning'],
      'source' => $variables['line'],
    );
    if (drush_get_option('checkstyle')) {
      $checkstyle_levels = array(
        'minor' => 'info',
        'normal' => 'warning',
        'critical' => 'error',
      );
      $attr['severity'] = $checkstyle_levels[$variables['severity_name']];
    }
    return '<error ' . _coder_review_drupal_attributes($attr) . ' />';
  }

  // Return warning as text output, formatted for the drush screen.
  $output = $variables['lineno'] ? ($variables['lineno'] == -1 ? dt('File') : '+' . $variables['lineno']) . ': ' : '';
  if (drush_get_option('ignorename')) {
    $output .= '[' . $variables['review_name'] . '_' . $variables['rule_name'] . ', ' . $variables['severity_name'] . '] ';
  }
  else {
    $output .= '[' . $variables['severity_name'] . '] ';
  }
  if (is_string($variables['warning'])) {
    $output .= $variables['warning'];
  }
  elseif (isset($variables['warning']['#warning'])) {
    $output .= dt($variables['warning']['#warning']);
  }
  elseif (isset($variables['warning']['#text'])) {
    $variables['warning'] += array(
      '#args' => array(),
    );
    $output .= call_user_func('dt', $variables['warning']['#text'], $variables['warning']['#args']);
  }
  return _coder_review_drush_output($output);
}