Example #1
0
def cli(ctx, path, **kwds):
    """Check specified tool(s) for common errors and adherence to best
    practices.
    """
    lint_args = build_lint_args(**kwds)
    exit = lint_tools_on_path(ctx, path, lint_args)
    sys.exit(exit)
Example #2
0
def lint_repository(ctx, path, **kwds):
    info("Linting repository %s" % path)
    lint_args = build_lint_args(ctx, **kwds)
    lint_ctx = LintContext(lint_args["level"])
    lint_ctx.lint(
        "tool_dependencies",
        lint_tool_dependencies,
        path,
    )
    lint_ctx.lint(
        "repository_dependencies",
        lint_repository_dependencies,
        path,
    )
    lint_ctx.lint(
        "shed_yaml",
        lint_shed_yaml,
        path,
    )
    lint_ctx.lint(
        "readme",
        lint_readme,
        path,
    )
    if kwds["tools"]:
        for (tool_path, tool_xml) in yield_tool_xmls(ctx, path,
                                                     recursive=True):
            info("+Linting tool %s" % tool_path)
            lint_xml_with(lint_ctx,
                          tool_xml,
                          extra_modules=lint_args["extra_modules"])
    failed = lint_ctx.failed(lint_args["fail_level"])
    if failed:
        error("Failed linting")
    return 1 if failed else 0
Example #3
0
def cli(ctx, paths, **kwds):
    """Check specified tool(s) for common errors and adherence to best
    practices.
    """
    lint_args = build_lint_args(ctx, **kwds)
    exit = lint_tools_on_path(
        ctx,
        paths,
        lint_args,
        recursive=kwds["recursive"]
    )
    sys.exit(exit)
Example #4
0
def cli(ctx, paths, **kwds):
    """Check specified tool(s) for common errors and adherence to best
    practices.
    """
    lint_args = build_lint_args(ctx, **kwds)
    exit = lint_tools_on_path(ctx,
                              paths,
                              lint_args,
                              recursive=kwds["recursive"])

    # TODO: rearchitect XUnit.
    # if kwds['urls']:
    #         collected_data, url_exit_code = check_urls(ctx, paths, **kwds)
    #         if kwds.get('report_xunit', False):
    #             with open(kwds['report_xunit'], 'w') as handle:
    #                 handle.write(build_report.template_data(
    #                     collected_data, template_name='xunit.tpl'))
    sys.exit(exit)
Example #5
0
def cli(ctx, paths, **kwds):
    """Check tools for common errors and adherence to best practices."""
    lint_args = build_lint_args(ctx, **kwds)
    exit_code = lint_tools_on_path(
        ctx,
        paths,
        lint_args,
        recursive=kwds["recursive"]
    )

    # TODO: rearchitect XUnit.
    # if kwds['urls']:
    #         collected_data, url_exit_code = check_urls(ctx, paths, **kwds)
    #         if kwds.get('report_xunit', False):
    #             with open(kwds['report_xunit'], 'w') as handle:
    #                 handle.write(build_report.template_data(
    #                     collected_data, template_name='xunit.tpl'))
    ctx.exit(exit_code)
Example #6
0
def lint_repository(ctx, path, **kwds):
    info("Linting repository %s" % path)
    lint_args = build_lint_args(ctx, **kwds)
    lint_ctx = LintContext(lint_args["level"])
    lint_ctx.lint(
        "tool_dependencies",
        lint_tool_dependencies,
        path,
    )
    lint_ctx.lint(
        "repository_dependencies",
        lint_repository_dependencies,
        path,
    )
    lint_ctx.lint(
        "shed_yaml",
        lint_shed_yaml,
        path,
    )
    lint_ctx.lint(
        "readme",
        lint_readme,
        path,
    )
    if kwds["tools"]:
        for (tool_path, tool_xml) in yield_tool_xmls(ctx, path,
                                                     recursive=True):
            info("+Linting tool %s" % tool_path)
            lint_xml_with(
                lint_ctx,
                tool_xml,
                extra_modules=lint_args["extra_modules"]
            )
    failed = lint_ctx.failed(lint_args["fail_level"])
    if failed:
        error("Failed linting")
    return 1 if failed else 0
Example #7
0
def lint_repository(ctx, realized_repository, **kwds):
    # TODO: this really needs to start working with realized path.
    failed = False
    path = realized_repository.real_path
    info("Linting repository %s" % path)
    lint_args = build_lint_args(ctx, **kwds)
    lint_ctx = LintContext(lint_args["level"])
    lint_ctx.lint(
        "lint_expansion",
        lint_expansion,
        realized_repository,
    )
    lint_ctx.lint(
        "lint_expected_files",
        lint_expected_files,
        realized_repository,
    )
    lint_ctx.lint(
        "lint_tool_dependencies_xsd",
        lint_tool_dependencies_xsd,
        path,
    )
    lint_ctx.lint(
        "lint_tool_dependencies_actions",
        lint_tool_dependencies_actions,
        path,
    )
    lint_ctx.lint(
        "lint_repository_dependencies",
        lint_repository_dependencies,
        path,
    )
    lint_ctx.lint(
        "lint_shed_yaml",
        lint_shed_yaml,
        realized_repository,
    )
    lint_ctx.lint(
        "lint_readme",
        lint_readme,
        path,
    )
    if kwds["urls"]:
        lint_ctx.lint(
            "lint_urls",
            lint_tool_dependencies_urls,
            path,
        )
    if kwds["tools"]:
        for (tool_path, tool_source) in yield_tool_sources(ctx, path,
                                                           recursive=True):
            info("+Linting tool %s" % tool_path)
            if handle_tool_load_error(tool_path, tool_source):
                failed = True
                continue
            lint_tool_source_with(
                lint_ctx,
                tool_source,
                extra_modules=lint_args["extra_modules"]
            )
    if kwds["ensure_metadata"]:
        lint_ctx.lint(
            "lint_shed_metadata",
            lint_shed_metadata,
            realized_repository,
        )
    if not failed:
        failed = lint_ctx.failed(lint_args["fail_level"])
    if failed:
        error("Failed linting")
    return 1 if failed else 0
Example #8
0
def lint_repository(ctx, realized_repository, **kwds):
    # TODO: this really needs to start working with realized path.
    failed = False
    path = realized_repository.real_path
    info("Linting repository %s" % path)
    lint_args = build_lint_args(ctx, **kwds)
    lint_ctx = LintContext(lint_args["level"])
    lint_ctx.lint(
        "lint_expansion",
        lint_expansion,
        realized_repository,
    )
    lint_ctx.lint(
        "lint_expected_files",
        lint_expected_files,
        realized_repository,
    )
    lint_ctx.lint(
        "lint_tool_dependencies_xsd",
        lint_tool_dependencies_xsd,
        path,
    )
    lint_ctx.lint(
        "lint_tool_dependencies_actions",
        lint_tool_dependencies_actions,
        path,
    )
    lint_ctx.lint(
        "lint_repository_dependencies",
        lint_repository_dependencies,
        path,
    )
    lint_ctx.lint(
        "lint_shed_yaml",
        lint_shed_yaml,
        realized_repository,
    )
    lint_ctx.lint(
        "lint_readme",
        lint_readme,
        path,
    )
    if kwds["tools"]:
        for (tool_path, tool_xml) in yield_tool_xmls(ctx, path,
                                                     recursive=True):
            info("+Linting tool %s" % tool_path)
            if handle_tool_load_error(tool_path, tool_xml):
                failed = True
                continue
            lint_xml_with(lint_ctx,
                          tool_xml,
                          extra_modules=lint_args["extra_modules"])
    if kwds["ensure_metadata"]:
        lint_ctx.lint(
            "lint_shed_metadata",
            lint_shed_metadata,
            realized_repository,
        )
    if not failed:
        failed = lint_ctx.failed(lint_args["fail_level"])
    if failed:
        error("Failed linting")
    return 1 if failed else 0