You are here

function coder_parse_ignores in Coder 6.2

Parse an 'ignore' file.

1 call to coder_parse_ignores()
coder_get_ignores in ./coder.module
Get list of lines to ignore.

File

./coder.module, line 1889

Code

function coder_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;
}