Skip to content

Commit

Permalink
Merge pull request #104 from bwrsandman/recursive-source-config
Browse files Browse the repository at this point in the history
Fix Recursive source clang-tidy
  • Loading branch information
ZedThree authored Jan 12, 2024
2 parents 7e7ae43 + 7765f56 commit 0dd8d19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions post/clang_tidy_review/clang_tidy_review/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ def build_clang_tidy_warnings(

config = config_file_or_checks(clang_tidy_binary, clang_tidy_checks, config_file)

print(f"Using config: {config}")

args = [
clang_tidy_binary,
f"-p={build_dir}",
config,
f"-line-filter={line_filter}",
f"--export-fixes={FIXES_FILE}",
] + files
]

if config:
print(f"Using config: {config}")
args.append(config)
else:
print("Using recursive directory config")

args += files

start = datetime.datetime.now()
try:
Expand Down Expand Up @@ -116,13 +121,13 @@ def clang_tidy_version(clang_tidy_binary: pathlib.Path):

def config_file_or_checks(
clang_tidy_binary: pathlib.Path, clang_tidy_checks: str, config_file: str
):
) -> Optional[str]:
version = clang_tidy_version(clang_tidy_binary)

if config_file == "":
if clang_tidy_checks:
return f"--checks={clang_tidy_checks}"
return ""
return None

if version >= 12:
return f"--config-file={config_file}"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def test_config_file(monkeypatch, tmp_path):
flag = ctr.config_file_or_checks(
"not-clang-tidy", clang_tidy_checks="", config_file=""
)
assert flag == f""
assert flag is None

# If you get config_file to something, config_file is sent to clang-tidy.
flag = ctr.config_file_or_checks(
Expand Down

0 comments on commit 0dd8d19

Please sign in to comment.