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

[clang-tidy] Fix Clang tidy checker option output #4050

Merged
merged 1 commit into from
Oct 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def parse_checker_config_old(config_dump):
config_dump -- clang-tidy config options YAML dump in pre-LLVM15 format.
"""
reg = re.compile(r'key:\s+(\S+)\s+value:\s+([^\n]+)')
return re.findall(reg, config_dump)
all = re.findall(reg, config_dump)
# tidy emits the checker option with a "." prefix, but we need a ":"
all = [(option[0].replace(".", ":"), option[1]) for option in all]
return all


def parse_checker_config_new(config_dump):
Expand All @@ -82,7 +85,7 @@ def parse_checker_config_new(config_dump):
if 'CheckOptions' not in data:
return None

return [[key, value]
return [[key.replace(".", ":"), value]
for (key, value) in data['CheckOptions'].items()]
except ImportError:
return None
Expand Down
4 changes: 2 additions & 2 deletions analyzer/tests/unit/test_checker_option_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_old_format(self):
result = [[k, v] for (k, v) in result]
self.assertEqual(len(result), 6)
self.assertIn(
["readability-suspicious-call-argument.PrefixSimilarAbove",
["readability-suspicious-call-argument:PrefixSimilarAbove",
"'30'"], result)

def test_new_format(self):
Expand Down Expand Up @@ -86,5 +86,5 @@ def test_new_format(self):
result = [[k, v] for (k, v) in result]
self.assertEqual(len(result), 6)
self.assertIn(
["readability-suspicious-call-argument.PrefixSimilarAbove", "30"],
["readability-suspicious-call-argument:PrefixSimilarAbove", "30"],
result)
Loading