def run(self, path): # In is_tracking_an_upstream_file, the path is opened. # To avoid invoking it many times for a file, we cache the result, and # pass it to Linter.should_run() method via an argument. is_tracking_upstream = analyze_diffs.is_tracking_an_upstream_file(path) group = LinterRunner._EXTENSION_GROUP_MAP.get( os.path.splitext(path)[1].lower()) result = True for linter in self._linter_list: # Common rule to check if linter should be applied to the file. if (linter.name in self._ignore_rule.get(path, []) or (linter.target_groups and group not in linter.target_groups) or (linter.ignore_upstream_tracking_file and is_tracking_upstream) or (linter.ignore_mods and path.startswith('mods/'))): continue # Also, check each linter specific rule. if not linter.should_run(path): continue logging.info('%- 10s: %s', linter.name, path) result &= linter.run(path) if not result: logging.error('%s: has lint errors', path) return result
def run(self, path): # In is_tracking_an_upstream_file, the path is opened. # To avoid invoking it many times for a file, we cache the result, and # pass it to Linter.should_run() method via an argument. is_tracking_upstream = analyze_diffs.is_tracking_an_upstream_file(path) group = LinterRunner._EXTENSION_GROUP_MAP.get(os.path.splitext(path)[1].lower()) result = True for linter in self._linter_list: # Common rule to check if linter should be applied to the file. if ( linter.name in self._ignore_rule.get(path, []) or (linter.target_groups and group not in linter.target_groups) or (linter.ignore_upstream_tracking_file and is_tracking_upstream) or (linter.ignore_mods and path.startswith("mods/")) ): continue # Also, check each linter specific rule. if not linter.should_run(path): continue logging.info("%- 10s: %s", linter.name, path) result &= linter.run(path) if not result: logging.error("%s: has lint errors", path) return result
def _get_all_mod_stats_for_upstream_refs(mod_stats, dir): for file_name in _walk(dir): if analyze_diffs.is_tracking_an_upstream_file(file_name): analyze_diffs.get_file_mod_stats_for_upstream_refs(file_name, mod_stats)