Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Recursive source clang-tidy #104

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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