diff --git a/post/clang_tidy_review/clang_tidy_review/__init__.py b/post/clang_tidy_review/clang_tidy_review/__init__.py index b797b5e..7b2475b 100644 --- a/post/clang_tidy_review/clang_tidy_review/__init__.py +++ b/post/clang_tidy_review/clang_tidy_review/__init__.py @@ -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: @@ -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}" diff --git a/tests/test_review.py b/tests/test_review.py index c3b3916..7368429 100644 --- a/tests/test_review.py +++ b/tests/test_review.py @@ -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(