function do_coder_reviews in Coder 5
Same name and namespace in other branches
- 5.2 coder.module \do_coder_reviews()
- 6.2 coder.module \do_coder_reviews()
- 6 coder.module \do_coder_reviews()
- 7.2 coder_review/coder_review.common.inc \do_coder_reviews()
- 7 coder_review/coder_review.module \do_coder_reviews()
2 calls to do_coder_reviews()
File
- ./
coder.module, line 650 - 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 do_coder_reviews($coder_args) {
// the cache is still experimental, so users must enable it
if ($use_cache = variable_get('coder_cache', 1)) {
// cache the results because:
$cache_key = 'coder:' . implode(':', array_keys($coder_args['#reviews'])) . $coder_args['#severity'] . ':' . $coder_args['#filename'];
$cache_mtime = filemtime(realpath($coder_args['#filename']));
if ($cache_results = cache_get($cache_key)) {
if ($cache_results->data['mtime'] == $cache_mtime && ($x = _coder_modified()) < $cache_results->created) {
return unserialize($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_read_and_parse_file($coder_args)) {
// do all of the code reviews
foreach ($coder_args['#reviews'] as $review) {
if ($result = do_coder_review($coder_args, $review)) {
$results += $result;
}
}
// sort the results
ksort($results, SORT_NUMERIC);
}
else {
_coder_error_msg($results, t('Could not read the file'), 'critical');
}
// save the results in the cache
if ($use_cache) {
$cache_results = array(
'mtime' => $cache_mtime,
'results' => $results,
);
cache_set($cache_key, 'cache', serialize($cache_results));
}
return $results;
}