Given every message which was emitted by the tools, and the
    list of files to inspect, create a list of files to ignore,
    and a map of filepath -> line-number -> codes to ignore
961133
def get_suppressions(relative_filepaths, root, messages):
    
    paths_to_ignore = set()
    lines_to_ignore = defaultdict(set)
    messages_to_ignore = defaultdict(lambda: defaultdict(set))

    # first deal with 'noqa' style messages
    for filepath in relative_filepaths:
        abspath = os.path.join(root, filepath)

        try:
            file_contents = encoding.read_py_file(abspath).split('\n')
        except encoding.CouldNotHandleEncoding as err:
            # TODO: this output will break output formats such as JSON
            warnings.warn('{0}: {1}'.format(err.path, err.cause), ImportWarning)
            continue

        ignore_file, ignore_lines = get_noqa_suppressions(file_contents)
        if ignore_file:
            paths_to_ignore.add(filepath)
        lines_to_ignore[filepath] |= ignore_lines

    # now figure out which messages were suppressed by pylint
    pylint_ignore_files, pylint_ignore_messages = _parse_pylint_informational(messages)
    paths_to_ignore |= pylint_ignore_files
    for filepath, line in pylint_ignore_messages.items():
        for line_number, codes in line.items():
            for code in codes:
                messages_to_ignore[filepath][line_number].add(('pylint', code))
                if code in _PYLINT_EQUIVALENTS:
                    for equivalent in _PYLINT_EQUIVALENTS[code]:
                        messages_to_ignore[filepath][line_number].add(equivalent)

    return paths_to_ignore, lines_to_ignore, messages_to_ignore
1355701
def listen_ignore_paths(options)
      source = Pathname.new(options["source"]).expand_path
      paths  = to_exclude(options)

      paths.map do |p|
        absolute_path = Pathname.new(normalize_encoding(p, options["source"].encoding)).expand_path
        next unless absolute_path.exist?

        begin
          relative_path = absolute_path.relative_path_from(source).to_s
          relative_path = File.join(relative_path, "") if absolute_path.directory?
          unless relative_path.start_with?("../")
            path_to_ignore = %r!^#{Regexp.escape(relative_path)}!
            Jekyll.logger.debug "Watcher:", "Ignoring #{path_to_ignore}"
            path_to_ignore
          end
        rescue ArgumentError
          # Could not find a relative path
        end
      end.compact + [%r!^\.jekyll\-metadata!]
    end
1058184
def clean(outputdir, drivers=None):
    
    if drivers:
        # Generate a list of tuples: [(driver_name, requested_version)]
        # If driver string does not contain a version, the second element
        # of the tuple is None.
        # Example:
        # [('driver_a', '2.2'), ('driver_b', None)]
        drivers_split = [helpers.split_driver_name_and_version(x) for x in
                         drivers]
        file_data = [(helpers.normalize_driver_name(x[0]), x[1]) for x in
                     drivers_split]
    else:
        file_data = [(x, None) for x in config.ALL_DRIVERS]

    files = [file for file in os.listdir(outputdir)
             if os.path.isfile(os.path.join(outputdir, file))]
    for file in files:
        for data in file_data:
            prefix, version = data
            starts_with = file.startswith(prefix)
            version_match = 'N/A'
            if version is not None:
                file_version = helpers.extract_version_from_filename(file)
                if file_version == version:
                    version_match = True
                else:
                    version_match = False
            if starts_with and version_match in [True, 'N/A']:
                filepath = os.path.join(outputdir, file)
                try:
                    os.remove(filepath)
                except OSError:
                    pass
                finally:
                    logger.info('removed {}'.format(file))
                    break
748426
def list_files(x, path=""):
    
    logger_directory.info("enter list_files")
    file_list = []
    if path:
        # list files from target directory
        files = os.listdir(path)
        for file in files:
            if file.endswith(x) and not file.startswith(("$", "~", ".")):
                # join the path and basename to create full path
                file_list.append(os.path.join(path, file))
    else:
        # list files from current working directory
        files = os.listdir()
        for file in files:
            if file.endswith(x) and not file.startswith(("$", "~", ".")):
                # append basename. not full path
                file_list.append(file)
    logger_directory.info("exit list_files")
    return file_list
216811
def file_list(path, ext = 'scss', remover = '')
      # Necessary so that directories aren't counted
      collect_path = path.include?("*") ? path : "#{path}/**/*.#{ext}"
      # Remove first slash from path if present. probably a better way to do this.
      Dir[collect_path].collect { |file| file.gsub(remover, '').gsub(/^\/app\//, 'app/') if File.file?(file) }
    end
295075
def notice_contents
      Dir.glob(dir_path.join("*"))
         .grep(LEGAL_FILES_PATTERN)
         .select { |path| File.file?(path) }
         .sort # sorted by the path
         .map { |path| { "sources" => normalize_source_path(path), "text" => File.read(path).rstrip } }
         .select { |notice| notice["text"].length > 0 } # files with content only
    end
131334
def iter_source_code(paths: Iterable[str], config: MutableMapping[str, Any], skipped: List[str]) -> Iterator[str]:
    """"""
    if 'not_skip' in config:
        config['skip'] = list(set(config['skip']).difference(config['not_skip']))

    for path in paths:
        if os.path.isdir(path):
            for dirpath, dirnames, filenames in os.walk(path, topdown=True, followlinks=True):
                for dirname in list(dirnames):
                    if file_should_be_skipped(dirname, config, dirpath):
                        skipped.append(dirname)
                        dirnames.remove(dirname)
                for filename in filenames:
                    filepath = os.path.join(dirpath, filename)
                    if is_python_file(filepath):
                        relative_file = os.path.relpath(filepath, path)
                        if file_should_be_skipped(relative_file, config, path):
                            skipped.append(filename)
                        else:
                            yield filepath
        else:
            yield path
1342178
def _compile_messages(self):
        '''
        
        '''
        self.compiled_messages = []
        if not self._config:
            return
        for message_dict in self._config.get('messages', {}):
            error = message_dict['error']
            tag = message_dict['tag']
            model = message_dict['model']
            match_on = message_dict.get('match_on', 'tag')
            if '__python_fun__' in message_dict:
                self.compiled_messages.append({
                    'error': error,
                    'tag': tag,
                    'match_on': match_on,
                    'model': model,
                    '__python_fun__': message_dict['__python_fun__']
                })
                continue
            values = message_dict['values']
            line = message_dict['line']
            mapping = message_dict['mapping']
            # We will now figure out which position each value is in so we can use it with the match statement
            position = {}
            replace = {}
            for key in values.keys():
                if '|' in key:
                    new_key, replace[new_key] = key.replace(' ', '').split('|')
                    values[new_key] = values.pop(key)
                    key = new_key
                position[line.find('{' + key + '}')] = key
            sorted_position = {}
            for i, elem in enumerate(sorted(position.items())):
                sorted_position[elem[1]] = i + 1
            # Escape the line, then remove the escape for the curly bracets so they can be used when formatting
            escaped = re.escape(line).replace(r'\{', '{').replace(r'\}', '}')
            # Replace a whitespace with \s+
            escaped = escaped.replace(r'\ ', r'\s+')
            self.compiled_messages.append(
                {
                    'error': error,
                    'tag': tag,
                    'match_on': match_on,
                    'line': re.compile(escaped.format(**values)),
                    'positions': sorted_position,
                    'values': values,
                    'replace': replace,
                    'model': model,
                    'mapping': mapping
                }
            )
        log.debug('Compiled messages:')
        log.debug(self.compiled_messages)
289725
function listFiles(root, options) {
    options = _.defaults(options || {}, {
        ignoreFiles: [],
        ignoreRules: []
    });

    var d = Q.defer();

    // Our list of files
    var files = [];

    var ig = Ignore({
        path: root,
        ignoreFiles: options.ignoreFiles
    });

    // Add extra rules to ignore common folders
    ig.addIgnoreRules(options.ignoreRules, '__custom_stuff');

    // Push each file to our list
    ig.on('child', function (c) {
        files.push(
            c.path.substr(c.root.path.length + 1) + (c.props.Directory === true ? '/' : '')
        );
    });

    ig.on('end', function() {
        // Normalize paths on Windows
        if(process.platform === 'win32') {
            return d.resolve(files.map(function(file) {
                return file.replace(/\\/g, '/');
            }));
        }

        // Simply return paths otherwise
        return d.resolve(files);
    });

    ig.on('error', d.reject);

    return d.promise;
}
197192
def main(directories):
    ''''''
    msg = 'Checking module "{}" from directory "{}" for coding errors.'
    api_checker = ApiChecker()
    resource_checker = ResourceChecker()
    errors = []
    modules = []
    for loader, mname, _ in pkgutil.walk_packages(directories):
        sys.path.append(os.path.abspath(loader.path))
        log.info(msg.format(mname, loader.path))
        modules.append(mname)
        import_module(mname)
    for api in Api:
        if api.__module__.split('.')[-1] not in modules:
            continue
        log.debug('Anlysing Api class: {}'.format(api.__name__))
        errors.extend(api_checker(api))
    for res in Resource:
        if res.__module__.split('.')[-1] not in modules:
            continue
        log.debug('Anlysing Resource class: {}'.format(res.__name__))
        errors.extend(resource_checker(res))
    else:
        log.info('All modules tested, no problem detected.')
    return errors
110655
def all_warnings_for_line(line, line_number, filename)
      new_warnings = check_for_indent_warnings!(line, filename)
      new_warnings.concat scan_for_line_warnings(line, filename)
      new_warnings.each {|warning| warning.line_number = line_number}
    end
575565
def from_data(cls, data):
        
        messages = []
        filename = data['checker']['filename']
        for m in data['messages']:
            for l in m['locations']:
                location = l['path']
                if not location.startswith(filename):
                    location = filename + '/' + location
                if l['line'] != -1:
                    location += ':{}'.format(l['line'])
                if l['column'] != -1:
                    location += ':{}'.format(l['column'])
                messages.append(
                    cls(m['ID'], m['severity'], location, m['message'], m['suggestion'])
                )
        return messages
392226
def warn(message, ids: [], &block)
      msg = ids.empty? ? '' : "[#{ids.map!(&:to_s).map(&:inspect).join(', ')}] "
      msg += message
      @logger.warn(msg, &block) unless (@ignored & ids).any?
    end
1283682
def ignore_directories(self, project):
        
        project_list = False
        try:
            ignore_directories = il['ignore_directories']
        except KeyError:
            logger.error('Key Error processing ignore_directories list values')

        try:
            project_exceptions = il.get('project_exceptions')
            for item in project_exceptions:
                if project in item:
                    exception_file = item.get(project)
                    with open(exception_file, 'r') as f:
                        test_list = yaml.safe_load(f)
                        project_list = test_list['ignore_directories']
        except KeyError:
            logger.info('No ignore_directories for %s', project)

        if project_list:
            ignore_directories = ignore_directories + project_list
            return ignore_directories
        else:
            return ignore_directories
56198
def _run_lint_on_file_stamped_args(file_path,  # suppress(too-many-arguments)
                                   stamp_file_path,
                                   log_technical_terms_to,
                                   linter_functions,
                                   tool_options,
                                   fix_what_you_can):
    """"""
    dictionary_path = os.path.abspath("DICTIONARY")
    dependencies = [file_path]

    if os.path.exists(dictionary_path):
        dependencies.append(dictionary_path)

    kwargs = OrderedDict()
    kwargs["jobstamps_dependencies"] = dependencies
    kwargs["jobstamps_cache_output_directory"] = stamp_file_path

    if log_technical_terms_to:
        kwargs["jobstamps_output_files"] = [log_technical_terms_to]

    return ((file_path,
             linter_functions,
             tool_options,
             fix_what_you_can),
            kwargs)
720238
def filter(self, info, releases):
        

        # Make a copy of releases keys
        # as we may delete packages during iteration
        removed = 0
        versions = list(releases.keys())
        for version in versions:
            new_files = []
            for file_desc in releases[version]:
                if self._check_match(file_desc):
                    removed += 1
                else:
                    new_files.append(file_desc)
            if len(new_files) == 0:
                del releases[version]
            else:
                releases[version] = new_files
        logger.debug(f"{self.name}: filenames removed: {removed}")
827234
def scan_for_line_warnings(line, filename)
      warnings = scan_for_warnings(using & LineWarning.all_warnings, line, filename)
      filtered_warnings_from_line(line, warnings)
    end