You are here

function coder_review_print_drush_messages in Coder 7.2

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

Prints Coder review messages in a format for drush use.

Parameters

array $summary: An array of summary statistics about warnings and errors.

1 call to coder_review_print_drush_messages()
coder_review_page_form in coder_review/coder_review.module
Implements hook_form().

File

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

Code

function coder_review_print_drush_messages(array $summary) {

  // if --ignores-pass is set then ignores should not be summed and counted
  // against a shell exit code
  if (drush_get_option('ignores-pass') && isset($summary['sums']['ignored'])) {
    unset($summary['sums']['ignored']);
  }

  // Count the number of warnings/errors.
  $sum = array_sum($summary['sums']);
  _coder_review_exit($sum ? 0 : 1);

  // Display messages if there is something to display.
  $no_empty = _coder_review_drush_get_option_no('empty');
  if ($no_empty || $sum) {
    foreach (_message() as $type => $messages) {
      $output = _coder_review_drush_output(implode("\n ", $messages));
      if (!drush_get_option('checkstyle')) {
        if (drush_get_option('xml')) {
          _coder_review_drush_print('<status type="' . $type . '">' . $output . '</status>');
        }
        else {
          _coder_review_drush_print(dt(ucfirst($type) . ' Messages') . ":\n " . $output . "\n");
        }
      }
    }
  }
}