misra,cert: use premiumaddon if it exists
This commit is contained in:
parent
48f2524774
commit
ef28c579bf
|
@ -13,6 +13,7 @@ import argparse
|
|||
import cppcheckdata
|
||||
import sys
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
VERIFY = ('-verify' in sys.argv)
|
||||
VERIFY_EXPECTED = []
|
||||
|
@ -401,6 +402,8 @@ if __name__ == '__main__':
|
|||
parser = get_args_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
path_premium_addon = cppcheckdata.get_path_premium_addon()
|
||||
|
||||
if args.verify:
|
||||
VERIFY = True
|
||||
|
||||
|
@ -413,6 +416,14 @@ if __name__ == '__main__':
|
|||
if not args.quiet:
|
||||
print('Checking %s...' % dumpfile)
|
||||
|
||||
if path_premium_addon:
|
||||
premium_command = [path_premium_addon, '--cert', dumpfile]
|
||||
if args.cli:
|
||||
premium_command.append('--cli')
|
||||
for line in subprocess.check_output(premium_command).decode('ascii').split('\n'):
|
||||
if line.find('cert-') > 0:
|
||||
print(line.strip())
|
||||
|
||||
data = cppcheckdata.CppcheckData(dumpfile)
|
||||
|
||||
if VERIFY:
|
||||
|
|
|
@ -8,6 +8,8 @@ License: No restrictions, use this as you need.
|
|||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
from xml.etree import ElementTree
|
||||
|
@ -1364,3 +1366,12 @@ def reportSummary(dumpfile, summary_type, summary_data):
|
|||
with open(ctu_info_file, 'at') as f:
|
||||
msg = {'summary': summary_type, 'data': summary_data}
|
||||
f.write(json.dumps(msg) + '\n')
|
||||
|
||||
|
||||
def get_path_premium_addon():
|
||||
p = pathlib.Path(sys.argv[0]).parent.parent
|
||||
p1 = os.path.join(p, 'premiumaddon')
|
||||
p2 = os.path.join(p, 'cppcheck')
|
||||
if os.path.isfile(p1) and os.path.isfile(p2):
|
||||
return p1
|
||||
return None
|
||||
|
|
|
@ -1318,7 +1318,7 @@ class MisraChecker:
|
|||
self._ctu_summary_identifiers = False
|
||||
self._ctu_summary_usage = False
|
||||
|
||||
self.premium_addon = None
|
||||
self.path_premium_addon = None
|
||||
|
||||
def __repr__(self):
|
||||
attrs = ["settings", "verify_expected", "verify_actual", "violations",
|
||||
|
@ -4048,8 +4048,8 @@ class MisraChecker:
|
|||
misra_severity = self.ruleTexts[ruleNum].misra_severity
|
||||
cppcheck_severity = self.ruleTexts[ruleNum].cppcheck_severity
|
||||
elif len(self.ruleTexts) == 0:
|
||||
if self.premium_addon:
|
||||
errmsg = subprocess.check_output([self.premium_addon, '--get-rule-text=' + errorId]).strip().decode('ascii')
|
||||
if self.path_premium_addon:
|
||||
errmsg = subprocess.check_output([self.path_premium_addon, '--get-rule-text=' + errorId]).strip().decode('ascii')
|
||||
else:
|
||||
errmsg = 'misra violation (use --rule-texts=<file> to get proper output)'
|
||||
else:
|
||||
|
@ -4386,8 +4386,8 @@ class MisraChecker:
|
|||
self.executeCheck(2210, self.misra_22_10, cfg)
|
||||
|
||||
# Premium MISRA checking, deep analysis
|
||||
if cfgNumber == 0 and self.premium_addon:
|
||||
subprocess.call([self.premium_addon, '--misra', dumpfile])
|
||||
if cfgNumber == 0 and self.path_premium_addon:
|
||||
subprocess.call([self.path_premium_addon, '--misra', dumpfile])
|
||||
|
||||
def analyse_ctu_info(self, ctu_info_files):
|
||||
all_typedef_info = []
|
||||
|
@ -4572,7 +4572,6 @@ def get_args_parser():
|
|||
parser.add_argument("-generate-table", help=argparse.SUPPRESS, action="store_true")
|
||||
parser.add_argument("-verify", help=argparse.SUPPRESS, action="store_true")
|
||||
parser.add_argument("--severity", type=str, help="Set a custom severity string, for example 'error' or 'warning'. ")
|
||||
parser.add_argument("--premium-addon", type=str, default=None, help=argparse.SUPPRESS)
|
||||
return parser
|
||||
|
||||
|
||||
|
@ -4582,7 +4581,7 @@ def main():
|
|||
settings = MisraSettings(args)
|
||||
checker = MisraChecker(settings)
|
||||
|
||||
checker.premium_addon = args.premium_addon
|
||||
checker.path_premium_addon = cppcheckdata.get_path_premium_addon()
|
||||
|
||||
if args.generate_table:
|
||||
generateTable()
|
||||
|
@ -4645,8 +4644,8 @@ def main():
|
|||
|
||||
checker.analyse_ctu_info(ctu_info_files)
|
||||
|
||||
if args.file_list and args.premium_addon:
|
||||
premium_command = [args.premium_addon, '--misra', '--file-list', args.file_list]
|
||||
if args.file_list and checker.path_premium_addon:
|
||||
premium_command = [checker.path_premium_addon, '--misra', '--file-list', args.file_list]
|
||||
if args.cli:
|
||||
premium_command.append('--cli')
|
||||
for line in subprocess.check_output(premium_command).decode('ascii').split('\n'):
|
||||
|
|
Loading…
Reference in New Issue