function coder_review_parse_ignores in Coder 7
Parse an 'ignore' file.
1 call to coder_review_parse_ignores()
- coder_review_get_ignores in coder_review/
coder_review.module - Get list of lines to ignore.
File
- coder_review/
coder_review.module, line 1970
Code
function coder_review_parse_ignores($filepath, $line_prefix = '') {
$ignores = array();
// Ensure the file exists.
if (!is_file($filepath) || !is_readable($filepath)) {
drupal_set_message(t("File %file doesn't exist or isn't readable.", array(
'%file' => $filepath,
)), 'error');
return array();
}
// Read in the file contents.
$lines = file($filepath);
// Parse the contents.
foreach ($lines as $line) {
$line = trim($line);
if (empty($line) || preg_match('/^;/', $line, $matches)) {
continue;
}
$line = $line_prefix . $line;
// filename:lineo:review
$parts = explode(':', $line);
// $ignores[filename][review][] = lineno
$ignores[$parts[0]][$parts[2]][] = $parts[1];
}
return $ignores;
}