def analyze (project, logger): logger.info("Executing pep8 on project sources") _, report_file = execute_tool_on_source_files(project, "pep8", ["pep8"]) reports = read_file(report_file) if len(reports) > 0: logger.warn("Found %d warning%s produced by pep8", len(reports), "" if len(reports) == 1 else "s")
def analyze (project, logger): """ Applies the flake8 script to the sources of the given project. """ logger.info("Applying flake8 to project sources.") execution_result = execute_tool_on_source_files(project=project, name="flake8", command_and_arguments=["flake8"]) report_file = execution_result[1] report_lines = read_file(report_file) count_of_warnings = len(report_lines) if count_of_warnings > 0: logger.warn("flake8 found %d warning(s).", count_of_warnings)
def execute_pychecker (project, logger): command_line = build_command_line(project) logger.info("Executing pychecker on project sources: %s" % (' '.join(command_line))) _, report_file = execute_tool_on_modules(project, "pychecker", command_line, True) warnings = read_file(report_file) report = parse_pychecker_output(project, warnings) project.write_report("pychecker.json", render_report(report.to_json_dict())) if len(warnings) != 0: logger.warn("Found %d warning%s produced by pychecker. See %s for details.", len(warnings), "s" if len(warnings) != 1 else "", report_file) threshold = project.get_property("pychecker_break_build_threshold") if project.get_property("pychecker_break_build") and len(warnings) > threshold: raise BuildFailedException("Found warnings produced by pychecker")
def filter_resource (absolute_file_name, relative_file_name, dict, logger): __pychecker__ = "unusednames=relative_file_name" logger.debug("Filtering resource %s", absolute_file_name) content = "".join(read_file(absolute_file_name)) filtered = string.Template(content).safe_substitute(dict) write_file(absolute_file_name, filtered)