Skip to content

Commit 7577ad6

Browse files
authored
Fix #12375 (misra.py: cache --get-rule-text result from premiumaddon) (#5894)
1 parent 3cb0a31 commit 7577ad6

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

addons/misra.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4281,6 +4281,14 @@ def reportError(self, location, num1, num2):
42814281
errorId = 'c2012-' + str(num1) + '.' + str(num2)
42824282
misra_severity = 'Undefined'
42834283
cppcheck_severity = 'style'
4284+
if self.path_premium_addon and ruleNum not in self.ruleTexts:
4285+
for line in cppcheckdata.cmd_output([self.path_premium_addon, '--cli', '--get-rule-text=' + errorId]).split('\n'):
4286+
if len(line) > 1 and not line.startswith('{'):
4287+
errmsg = line.strip()
4288+
rule = Rule(num1, num2)
4289+
rule.text = errmsg
4290+
self.ruleTexts[rule.num] = rule
4291+
break
42844292
if ruleNum in self.ruleTexts:
42854293
errmsg = self.ruleTexts[ruleNum].text
42864294
if self.ruleTexts[ruleNum].misra_severity:
@@ -4291,11 +4299,6 @@ def reportError(self, location, num1, num2):
42914299
errmsg = 'misra violation (use --rule-texts=<file> to get proper output)'
42924300
else:
42934301
errmsg = 'misra violation (rule-texts-file not found: ' + self.ruleText_filename + ')'
4294-
if self.path_premium_addon:
4295-
for line in cppcheckdata.cmd_output([self.path_premium_addon, '--cli', '--get-rule-text=' + errorId]).split('\n'):
4296-
if len(line) > 1 and not line.startswith('{'):
4297-
errmsg = line.strip()
4298-
break
42994302
else:
43004303
errmsg = 'misra violation %s with no text in the supplied rule-texts-file' % (ruleNum)
43014304

0 commit comments

Comments
 (0)