do_coder_reviews($coder_args)Perform batch coder reviews for multiple files.
$coder_args Array of coder arguments, valid arguments are:
Array of results, in form:
sites/all/modules/coder/coder_review/coder_review.module, line 995
<?php
function do_coder_reviews($coder_args) {
// Load the cached results if they exist, but not for patches.
if (empty($coder_args['#patch']) && empty($coder_args['#test'])) {
$cache_key = 'coder:' . implode(':', array_keys($coder_args['#reviews'])) . $coder_args['#severity'] . ':' . $coder_args['#filename'];
if (file_exists($filepath = realpath($coder_args['#filename']))) {
$cache_mtime = filemtime($filepath);
if ($cache_results = cache_get($cache_key, 'cache_coder')) {
if ($cache_results->data['mtime'] == $cache_mtime && _coder_review_modified() < $cache_results->created) {
return $cache_results->data['results'];
}
}
}
}
$results = array('#stats' => array('minor' => 0, 'normal' => 0, 'critical' => 0));
// Skip php include files when the user requested severity is above minor.
if (isset($coder_args['#php_minor']) && drupal_substr($coder_args['#filename'], -4) == '.php') {
if ($coder_args['#severity'] > 1) {
return $results;
}
}
// Read the file.
if (_coder_review_read_and_parse_file($coder_args)) {
// Do all of the code reviews.
$errors = array();
foreach ($coder_args['#reviews'] as $review) {
if ($result = do_coder_review($coder_args, $review)) {
foreach (array('critical', 'normal', 'minor') as $severity_level) {
if (isset($result['#stats'][$severity_level])) {
$results['#stats'][$severity_level] += $result['#stats'][$severity_level];
}
}
$errors += $result;
}
}
// Theme the error messages.
foreach ($errors as $key => $error) {
if (is_numeric($key)) {
$results[$key] = theme('coder_review_warning_msg', $error);
}
}
// Sort the results.
ksort($results, SORT_NUMERIC);
}
else {
$results[] = theme('coder_review_warning', t('Could not read the file'), 'critical');
}
// Save the results in the cache if we're not reviewing a patch.
if (empty($coder_args['#patch']) && empty($coder_args['#test']) && isset($cache_mtime)) {
$cache_results = array(
'mtime' => $cache_mtime,
'results' => $results,
);
cache_set($cache_key, $cache_results, 'cache_coder');
}
return $results;
}
?>