def METHOD_NAME():
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument("inputfile", help="The input file containing the warnings")
    p.add_argument(
        "output", default="codereport_clang_tidy.json", help="The resulting JSON file"
    )
    p.add_argument(
        "--exclude",
        "-e",
        action="append",
        default=[],
        help="Exclude files that match any of these patterns",
    )
    p.add_argument(
        "--filter",
        action="append",
        default=[],
        help="Only include files that match any of these patterns",
    )
    p.add_argument(
        "--ignore",
        action="append",
        default=[],
        help="Ignore items with codes matching any of these patterns",
    )
    p.add_argument("--cwd", type=Path)
    p.add_argument("--strip-common", action="store_true")
    args = p.parse_args()
    with open(args.inputfile, "r", encoding="utf-8") as f:
        inputstr = f.read()
    items = parse_clang_tidy_output(inputstr)
    def select(item):
        accept = True
        if len(args.filter) > 0:
            accept = accept and all(fnmatch(item.path, e) for e in args.filter)
        accept = accept and not any(fnmatch(item.path, e) for e in args.exclude)
        accept = accept and not any(fnmatch(item.code, i) for i in args.ignore)
        return accept
    items = list(filter(select, items))
    if args.cwd:
        for item in items:
            item.path = (args.cwd / item.path).resolve()
    if args.strip_common:
        prefix = Path(os.path.commonprefix([i.path for i in items]))
        def subpath(m):
            path, line, col = m.groups()
            path = Path(path).resolve().relative_to(prefix)
            return f"{path}:{line}:{col}:"
        for item in items:
            item.path = item.path.relative_to(prefix)
            item.message = re.sub(r"([\w/.\-+]+):(\d+):(\d+):", subpath, item.message)
    print("Write to", args.output)
    with open(args.output, "w+") as jf:
        jf.write(ItemCollection(__root__=items).json(indent=2))