Skip to content

Commit

Permalink
Merge pull request Ericsson#4050 from vodorok/tidy_opts_fix
Browse files Browse the repository at this point in the history
[clang-tidy] Fix Clang tidy checker option output
  • Loading branch information
bruntib authored Oct 26, 2023
2 parents 3999910 + 09a8cfb commit c016398
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py
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)

0 comments on commit c016398

Please sign in to comment.