diff --git a/post/clang_tidy_review/clang_tidy_review/__init__.py b/post/clang_tidy_review/clang_tidy_review/__init__.py index e095ea4..3ab4283 100644 --- a/post/clang_tidy_review/clang_tidy_review/__init__.py +++ b/post/clang_tidy_review/clang_tidy_review/__init__.py @@ -20,6 +20,7 @@ import re import io import zipfile +import shlex from github import Github from github.Requester import Requester from github.PaginatedList import PaginatedList @@ -763,12 +764,12 @@ def create_review( # Run clang-tidy with the configured parameters and produce the CLANG_TIDY_FIXES file build_clang_tidy_warnings( - line_ranges, + shlex.quote(line_ranges), build_dir, clang_tidy_checks, clang_tidy_binary, config_file, - '"' + '" "'.join(files) + '"', + shlex.join(files), ) # Read and parse the CLANG_TIDY_FIXES file @@ -887,7 +888,7 @@ def get_line_ranges(diff, files): line_filter_json = [] for name, lines in lines_by_file.items(): - line_filter_json.append(str({"name": name, "lines": lines})) + line_filter_json.append({"name": name, "lines": lines}) return json.dumps(line_filter_json, separators=(",", ":")) diff --git a/tests/test_review.py b/tests/test_review.py index 81a69c8..6acd7c6 100644 --- a/tests/test_review.py +++ b/tests/test_review.py @@ -231,7 +231,7 @@ def test_filter_files(): def test_line_ranges(): line_ranges = ctr.get_line_ranges(TEST_DIFF, ["src/hello.cxx"]) - expected_line_ranges = """["{'name': 'src/hello.cxx', 'lines': [[5, 16]]}"]""" + expected_line_ranges = '[{"name":"src/hello.cxx","lines":[[5,16]]}]' assert line_ranges == expected_line_ranges