A file should be checked against a rule unless it contains one of the whitelisted paths.
960228
boolean shouldCheckConformanceFor(String filePath) {
    for (String whitelistedPath : getWhitelistedPaths()) {
      if (filePath.contains(whitelistedPath)) {
        return false;
      }
    }
    ImmutableList<String> onlyApplyToPaths = getOnlyApplyToPaths();
    if (onlyApplyToPaths.isEmpty()) {
      return true;
    }
    // If only_apply_to field is presented in the configuration, check it.
    for (String onlyApplyToPath : onlyApplyToPaths) {
      if (filePath.contains(onlyApplyToPath)) {
        return true;
      }
    }
    return false;
  }
660502
def is_valid_file(parser,arg):
	""""""
	if not os.path.exists(arg):
       		parser.error("File %s not found"%arg)
	else:
	       	return arg
564538
function checkRequiredFiles() {
  const indexHtmlExists = fse.existsSync(paths.indexHtml);
  const indexJsExists = fse.existsSync(paths.indexJs);

  if (!indexHtmlExists || !indexJsExists) {
    logError('\nSome required files couldn\'t be found. Make sure these all exist:\n');
    logError(`\t- ${paths.indexHtml}`);
    logError(`\t- ${paths.indexJs}\n`);

    process.exit(1);
  }
}
1065280
public static final void checkFileType(Path path, String perms)
    {
        if (perms.length() != 10)
        {
            throw new IllegalArgumentException(perms+" not permission. E.g. -rwxr--r--");
        }
        switch (perms.charAt(0))
        {
            case '-':
                if (!Files.isRegularFile(path))
                {
                    throw new IllegalArgumentException("file is not regular file");
                }
                break;
            case 'd':
                if (!Files.isDirectory(path))
                {
                    throw new IllegalArgumentException("file is not directory");
                }
                break;
            case 'l':
                if (!Files.isSymbolicLink(path))
                {
                    throw new IllegalArgumentException("file is not symbolic link");
                }
                break;
            default:
                throw new UnsupportedOperationException(perms+" not supported");
        }
    }
781291
def matches(filter, message, valid_paths, rule_cache, config):
    

    if not filter['rules']:
        return False

    for rule in filter['rules']:
        fn = rule['fn']
        negated = rule['negated']
        arguments = rule['arguments']
        rule_cache_key = rule['cache_key']

        try:
            if rule_cache_key not in rule_cache:
                value = fn(config, message, **arguments)
                if negated:
                    value = not value
                rule_cache[rule_cache_key] =  value

            if not rule_cache[rule_cache_key]:
                return False
        except Exception as e:
            log.exception(e)
            # If something throws an exception then we do *not* have a match.
            return False

    # Then all rules matched on this filter..
    return True
1123030
def excluded?(file)
      file = File.join(Dir.pwd, file) unless file.start_with?('/')
      Codeqa.configuration.excludes.any?{ |pattern| match_path?(pattern, file) }
    end
18524
function checkMissingDir(destinationFile) {
  var filePath = path.dirname(destinationFile);
  var pathAbsolute = path.isAbsolute(filePath);
  var directories = filePath.split(path.sep);
  return transversePath(directories);
}
1192782
def _must_be_deleted(local_path, r_st):
        """"""
        # if the file doesn't exists
        if not os.path.lexists(local_path):
            return True

        # or if the file type is different
        l_st = os.lstat(local_path)
        if S_IFMT(r_st.st_mode) != S_IFMT(l_st.st_mode):
            return True

        return False
87503
def ensure_file(path):
        
        try:
            exists = isfile(path)
            if not exists:
                with open(path, 'w+') as fname:
                    fname.write('initialized')
                return (True, path)
            return (True, 'exists')
        except OSError as e:  # pragma: no cover
            return (False, e)
475677
function filter(p, rules, root, isDirectory, included) {
  p = path.relative(root, p);
  for (var i in rules) {
    var rule = rules[i];
    if (isDirectory) {
      if (rule.match(p) || rule.match("/" + p) ||
          rule.match(p + "/") || rule.match("/" + p + "/")
         ) {
        return rule.negate;
      }
    } else {
      if (rule.match(p) || rule.match("/" + p)) {
        return rule.negate;
      }
    }
  }
  return included;
}
1273643
@VisibleForTesting
  Set<String> retrieveWhitelist(FileSystem fs, Path path) {
    try {
      Preconditions.checkArgument(
          fs.exists(path), "File does not exist at " + path
      );
      Preconditions.checkArgument(
          fs.isFile(path), "Whitelist path is not a file. " + path
      );

      Set<String> result = Sets.newHashSet();
      try (BufferedReader br = new BufferedReader(new InputStreamReader(fs.open(path),
          StandardCharsets.UTF_8))) {
        String s = null;
        while (!StringUtils.isEmpty((s = br.readLine()))) {
          result.add(s);
        }
      }
      return result;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
821979
def should_skip(filename, config, path='/'):
    """"""
    for skip_path in config['skip']:
        if posixpath.abspath(posixpath.join(path, filename)) == posixpath.abspath(skip_path.replace('\\', '/')):
            return True

    position = os.path.split(filename)
    while position[1]:
        if position[1] in config['skip']:
            return True
        position = os.path.split(position[0])

    for glob in config['skip_glob']:
        if fnmatch.fnmatch(filename, glob):
            return True

    return False
1058814
function(filePath) {
        var ignoredPaths;

        if (this.options.ignore) {
            ignoredPaths = new IgnoredPaths(this.options);
            return ignoredPaths.contains(filePath);
        }

        return false;
    }
818202
def __check_to_permit(self, entry_type, entry_filename):
        """"""

        rules = self.__filter_rules[entry_type]

        # Should explicitly include?
        for pattern in rules[fss.constants.FILTER_INCLUDE]:
            if fnmatch.fnmatch(entry_filename, pattern):
                _LOGGER_FILTER.debug("Entry explicitly INCLUDED: [%s] [%s] "
                                     "[%s]", 
                                     entry_type, pattern, entry_filename)

                return True

        # Should explicitly exclude?
        for pattern in rules[fss.constants.FILTER_EXCLUDE]:
            if fnmatch.fnmatch(entry_filename, pattern):
                _LOGGER_FILTER.debug("Entry explicitly EXCLUDED: [%s] [%s] "
                                     "[%s]", 
                                     entry_type, pattern, entry_filename)

                return False

        # Implicitly include.

        _LOGGER_FILTER.debug("Entry IMPLICITLY included: [%s] [%s]", 
                             entry_type, entry_filename)

        return True
1169606
function isValidAbsolutePath(p) {
    var parsedPath;
    try {
        parsedPath = path.parse(p);
    } catch (error) {
        // Not a valid path if it can't be parsed.
        return false;
    }

    return (parsedPath.root === '/');
}
283859
function filterPaths(paths, allowed) {
  if (!allowed) { return []; }
  if (!allowed.only.length) { return paths; }

  return paths.filter(
    path => {
      let match = false;

      for (const filter of allowed.only) {
        try {
          switch (typeof filter) {
            case 'function':
              match = filter(path.path);
              break;
            case 'string':
              match = path.path === filter;
              break;
            default:
              match = filter.test(path.path);
         }
        } catch (e) {
          throw new Error(`${ typeof filter } is not an allowed filter type. Must be String, RegExp or Function`);
        }
        if (match) { return match; }
      }
      return match;
    }
  );
}
311004
def check_path(path, otherwise):
    

    if os.path.exists(path):
        print("WARNING: Path '%s' already exists; skipping" % path)
    else:
        otherwise(path)