print("No diagnostics or warnings produced by clang-tidy")
return 0
- gh_step_summary = os.getenv('GITHUB_STEP_SUMMARY')
+ gh_step_summary = os.getenv("GITHUB_STEP_SUMMARY")
if gh_step_summary:
# Print Markdown summary
- summaryFp = open(gh_step_summary, 'a', encoding='utf-8')
- print('### clang-tidy summary', file=summaryFp)
+ summary_fp = open(gh_step_summary, "a", encoding="utf-8")
+ print("### clang-tidy summary", file=summary_fp)
fixes = fixes["Diagnostics"]
have_warnings = False
line = helpers.get_line_from_offset(file_contents, offset)
- relative_filename = Path(full_filename).resolve().relative_to(repo_root_dir)
+ rel_filename = Path(full_filename).resolve().relative_to(repo_root_dir)
annotation = "".join(
[
- f"::warning file={relative_filename},line={line}",
+ f"::warning file={rel_filename},line={line}",
f"::{message} ({name} - Level={level})",
]
)
print(annotation)
# User-friendly printout
- print(f"{level}: {relative_filename}:{line}: {message} ({name})")
+ print(f"{level}: {rel_filename}:{line}: {message} ({name})")
if gh_step_summary:
- print(f'- **{relative_filename}:{line}** {message} (`{name}`)', file=summaryFp)
+ print(
+ f"- **{rel_filename}:{line}** {message} (`{name}`)",
+ file=summary_fp,
+ )
have_warnings = True
import helpers
import unidiff
+
def create_argument_parser():
"""Create command-line argument parser."""
parser = argparse.ArgumentParser(
diff = sys.stdin.read()
patch_set = unidiff.PatchSet(diff)
for patch in patch_set:
- # We have to deal with several possible cases for input files, as shown by git:
+ # We have to deal with several possible cases for input files, as shown
+ # by git:
+ #
# - in ext/: ext/lmdb-safe/lmdb-safe.cc
# - in modules/: modules/lmdbbackend/lmdbbackend.cc
- # - files that live in the dnsdist or rec dir only: pdns/dnsdistdist/dnsdist-dnsparser.cc or pdns/recursordist/rec-tcp.cc
- # - files that live in pdns/ and are used by several products (but possibly not with the same compilation flags, so
- # it is actually important that they are processed for all products: pdns/misc.cc
+ # - files that live in the dnsdist or rec dir only:
+ # pdns/dnsdistdist/dnsdist-dnsparser.cc or
+ # pdns/recursordist/rec-tcp.cc
+ # - files that live in pdns/ and are used by several products (but
+ # possibly not with the same compilation flags, so it is actually
+ # important that they are processed for all products: pdns/misc.cc
path = Path(patch.path)
- if product == 'auth':
+ if product == "auth":
path = Path(cwd).joinpath(path)
else:
- if str(path).startswith('modules'):
- print(f'Skipping {path}: modules do not apply to {product}', file=sys.stderr)
+ if str(path).startswith("modules"):
+ print(
+ f"Skipping {path}: modules do not apply to {product}",
+ file=sys.stderr,
+ )
continue
- if str(path).startswith('ext'):
+ if str(path).startswith("ext"):
subpath = Path(cwd).joinpath(path)
else:
subpath = Path(cwd).joinpath(path.name)
if not subpath.exists():
- print(f'Skipping {path}: does not exist for {product} ({subpath})', file=sys.stderr)
+ print(
+ f"Skip {path}: doesn't exist for {product} ({subpath})",
+ file=sys.stderr,
+ )
continue
path = subpath
patch.target_file = str(path)
if not str(path) in compdb:
- print(f'Skipping {path}: it is not in the compilation db', file=sys.stderr)
+ print(
+ f"Skipping {path}: it is not in the compilation db",
+ file=sys.stderr,
+ )
continue
print(patch, file=sys.stderr)