function do_coder_review in Coder 5.2
Same name and namespace in other branches
- 5 coder.module \do_coder_review()
- 6.2 coder.module \do_coder_review()
- 6 coder.module \do_coder_review()
- 7.2 coder_review/coder_review.common.inc \do_coder_review()
- 7 coder_review/coder_review.module \do_coder_review()
Perform code review for a review array.
Parameters
$coder_args: Array coder settings, must have been prepared with _coder_read_and_parse_file(), see do_coder_reviews() for format.
$review: Review array, see hook_review().
Return value
Array results, see do_coder_reviews() return value for format.
1 call to do_coder_review()
- do_coder_reviews in ./
coder.module - Perform batch coder reviews for multiple files.
File
- ./
coder.module, line 1189 - 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_review($coder_args, $review) {
$results = array();
if ($review['#rules']) {
// Get the review's severity, used when the rule severity is not defined.
$default_severity = _coder_severity($review['#severity']);
foreach ($review['#rules'] as $rule) {
// Perform the review if above the user requested severity.
$severity = _coder_severity(isset($rule['#severity']) ? $rule['#severity'] : '', $default_severity);
if ($severity >= $coder_args['#severity']) {
if (isset($rule['#original'])) {
// Deprecated.
$lines = $coder_args['#all_lines'];
}
elseif (isset($rule['#source'])) {
// Values: all, html, comment, allphp or php.
$source = '#' . $rule['#source'] . '_lines';
$lines = $coder_args[$source];
}
else {
$lines = $coder_args['#php_lines'];
}
if ($lines) {
switch ($rule['#type']) {
case 'regex':
do_coder_review_regex($coder_args, $review, $rule, $lines, $results);
break;
case 'grep':
do_coder_review_grep($coder_args, $review, $rule, $lines, $results);
break;
case 'grep_invert':
do_coder_review_grep_invert($coder_args, $review, $rule, $lines, $results);
break;
case 'callback':
do_coder_review_callback($coder_args, $review, $rule, $lines, $results);
break;
}
}
}
}
}
return $results;
}