def add_insert_cmd(subparsers):
    insert_help = ('Inserts a correct MIT-licence copyright header for "The '
                   'Bitcoin Core developers" at the top of files amongst the '
                   'selected targets where the header is expected but not '
                   'currently found.')
    parser = subparsers.add_parser('insert', help=insert_help)
    parser.set_defaults(cmd=lambda o: InsertCmd(o))
    add_git_tracked_targets_parameter(parser)
def add_update_cmd(subparsers):
    update_help = ('Updates the end year of the copyright headers of '
                   '"The Bitcoin Core developers" in files amongst the '
                   'selected targets which have been changed more recently '
                   'than the year that is listed.')
    parser = subparsers.add_parser('update', help=update_help)
    parser.set_defaults(cmd=lambda o: UpdateCmd(o))
    add_git_tracked_targets_parameter(parser)
def add_check_cmd(subparsers):
    check_help = ("Validates that selected targets do not have copyright "
                  "header issues, gives a per-file report and returns a "
                  "non-zero shell status if there are any issues discovered.")
    parser = subparsers.add_parser('check', help=check_help)
    parser.set_defaults(cmd=lambda o: CheckCmd(o))
    add_jobs_option(parser)
    add_json_option(parser)
    add_git_tracked_targets_parameter(parser)
def add_report_cmd(subparsers):
    report_help = ("Produces a report of copyright header notices within "
                   "selected targets to help identify files that don't meet "
                   "expectations.")
    parser = subparsers.add_parser('report', help=report_help)
    parser.set_defaults(cmd=lambda o: ReportCmd(o))
    add_jobs_option(parser)
    add_json_option(parser)
    add_git_tracked_targets_parameter(parser)
Example #5
0
def add_report_cmd(subparsers):
    report_help = ("Produces a report with the analysis of the code format "
                   "adherence of the selected targets taken as a group.")
    parser = subparsers.add_parser('report', help=report_help)
    parser.set_defaults(cmd=lambda o: ReportCmd(o))
    add_jobs_option(parser)
    add_json_option(parser)
    add_clang_options(parser, style_file=True)
    add_git_tracked_targets_parameter(parser)
Example #6
0
def add_report_cmd(subparsers):
    report_help = ("Validates that the selected targets do not have basic "
                   "style issues, give a per-file report and returns a "
                   "non-zero shell status if there are any basic style issues "
                   "discovered.")
    parser = subparsers.add_parser('report', help=report_help)
    parser.set_defaults(cmd=lambda o: ReportCmd(o))
    add_jobs_option(parser)
    add_json_option(parser)
    add_git_tracked_targets_parameter(parser)
Example #7
0
def add_check_cmd(subparsers):
    check_help = ("Validates that the selected targets match the style, gives "
                  "a per-file report and returns a non-zero shell status if "
                  "there are any format issues discovered.")
    parser = subparsers.add_parser('check', help=check_help)
    parser.set_defaults(cmd=lambda o: CheckCmd(o))
    add_jobs_option(parser)
    add_json_option(parser)
    add_clang_options(parser, style_file=True, force=True)
    add_git_tracked_targets_parameter(parser)
Example #8
0
def add_fix_cmd(subparsers):
    fix_help = ("Applies basic style fixes to the target files.")
    parser = subparsers.add_parser('fix', help=fix_help)
    parser.set_defaults(cmd=lambda o: FixCmd(o))
    add_jobs_option(parser)
    add_git_tracked_targets_parameter(parser)
Example #9
0
        repository_cmds = {
            'copyright_header': CopyrightHeaderCheck(settings),
            'basic_style': BasicStyleCheck(settings),
            'clang_format': ClangFormatCheck(settings),
            'clang_static_analysis': ClangStaticAnalysisCheck(settings),
        }
        self.json = settings.json
        super().__init__(settings, repository_cmds, silent=settings.json)

    def _output(self, results):
        if self.json:
            return super()._output(results)
        reports = [(self.repository_cmds[l].title + ":\n" +
                    self.repository_cmds[l]._output(r))
                   for l, r in sorted(results.items())]
        return '\n'.join(reports)


if __name__ == "__main__":
    description = ("Wrapper to invoke a collection of scripts that check on "
                   "the state of the repository.")
    parser = argparse.ArgumentParser(description=description)
    add_jobs_option(parser)
    add_json_option(parser)
    add_clang_options(parser, report_path=True, style_file=True, force=True)
    add_git_tracked_targets_parameter(parser)
    settings = parser.parse_args()
    finish_clang_settings(settings)
    checks = Checks(settings)
    checks.run()
Example #10
0
def add_format_cmd(subparsers):
    format_help = ("Applies the style formatting to the target files.")
    parser = subparsers.add_parser('format', help=format_help)
    parser.set_defaults(cmd=lambda o: FormatCmd(o))
    add_clang_options(parser, style_file=True, force=True)
    add_git_tracked_targets_parameter(parser)