Update misra.py to not run a few rules for cppcheck premium (#4970)

This commit is contained in:
Swasti Shrivastava 2023-04-15 22:05:34 +05:30 committed by GitHub
parent 89c33b4175
commit e575a84c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 12 deletions

View File

@ -4254,7 +4254,7 @@ class MisraChecker:
if (not self.is_cpp) or rule_num in misra_cpp: if (not self.is_cpp) or rule_num in misra_cpp:
check_function(*args) check_function(*args)
def parseDump(self, dumpfile): def parseDump(self, dumpfile, path_premium_addon=None):
def fillVerifyExpected(verify_expected, tok): def fillVerifyExpected(verify_expected, tok):
"""Add expected suppressions to verify_expected list.""" """Add expected suppressions to verify_expected list."""
rule_re = re.compile(r'[0-9]+\.[0-9]+') rule_re = re.compile(r'[0-9]+\.[0-9]+')
@ -4264,7 +4264,6 @@ class MisraChecker:
verify_expected.append('%s:%d %s' % (tok.file, tok.linenr, word)) verify_expected.append('%s:%d %s' % (tok.file, tok.linenr, word))
data = cppcheckdata.parsedump(dumpfile) data = cppcheckdata.parsedump(dumpfile)
typeBits['CHAR'] = data.platform.char_bit typeBits['CHAR'] = data.platform.char_bit
typeBits['SHORT'] = data.platform.short_bit typeBits['SHORT'] = data.platform.short_bit
typeBits['INT'] = data.platform.int_bit typeBits['INT'] = data.platform.int_bit
@ -4299,6 +4298,7 @@ class MisraChecker:
if not self.settings.quiet: if not self.settings.quiet:
self.printStatus('Checking %s, config %s...' % (dumpfile, cfg.name)) self.printStatus('Checking %s, config %s...' % (dumpfile, cfg.name))
if not path_premium_addon:
self.executeCheck(104, self.misra_1_4, cfg) self.executeCheck(104, self.misra_1_4, cfg)
self.executeCheck(202, self.misra_2_2, cfg) self.executeCheck(202, self.misra_2_2, cfg)
self.executeCheck(203, self.misra_2_3, dumpfile, cfg.typedefInfo) self.executeCheck(203, self.misra_2_3, dumpfile, cfg.typedefInfo)
@ -4346,6 +4346,7 @@ class MisraChecker:
self.executeCheck(904, self.misra_9_4, cfg) self.executeCheck(904, self.misra_9_4, cfg)
if cfgNumber == 0: if cfgNumber == 0:
self.executeCheck(905, self.misra_9_5, cfg, data.rawTokens) self.executeCheck(905, self.misra_9_5, cfg, data.rawTokens)
if not path_premium_addon:
self.executeCheck(1001, self.misra_10_1, cfg) self.executeCheck(1001, self.misra_10_1, cfg)
self.executeCheck(1002, self.misra_10_2, cfg) self.executeCheck(1002, self.misra_10_2, cfg)
self.executeCheck(1003, self.misra_10_3, cfg) self.executeCheck(1003, self.misra_10_3, cfg)
@ -4676,7 +4677,7 @@ def main():
checker.setSeverity(args.severity) checker.setSeverity(args.severity)
for item in dump_files: for item in dump_files:
checker.parseDump(item) checker.parseDump(item,checker.path_premium_addon)
if settings.verify: if settings.verify:
verify_expected = checker.get_verify_expected() verify_expected = checker.get_verify_expected()