diff --git a/addons/misra.py b/addons/misra.py index d970974ad..c31338910 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -13,6 +13,8 @@ # # Total number of rules: 143 +from __future__ import print_function + import cppcheckdata import sys import re @@ -24,10 +26,15 @@ ruleTexts = {} VERIFY = False SHOW_SUMMARY = True +QUIET = False VERIFY_EXPECTED = [] VERIFY_ACTUAL = [] VIOLATIONS = [] +def printStatus(*args, **kwargs): + if not QUIET: + print(*args, **kwargs) + def reportError(location, num1, num2): if VERIFY: VERIFY_ACTUAL.append(str(location.linenr) + ':' + str(num1) + '.' + str(num2)) @@ -1498,6 +1505,8 @@ OPTIONS: Rule 1.2 Rule text for 1.2 <...> + +--quiet Only print something when there is an error """) sys.exit(1) @@ -1569,6 +1578,8 @@ for arg in sys.argv[1:]: generateTable() elif arg == "--no-summary": SHOW_SUMMARY = False + elif arg == "--quiet": + QUIET = True else: print('Fatal error: unhandled argument ' + arg) sys.exit(1) @@ -1597,14 +1608,14 @@ for arg in sys.argv[1:]: if compiled.match(word): VERIFY_EXPECTED.append(str(tok.linenr) + ':' + word) else: - print('Checking ' + arg + '...') + printStatus('Checking ' + arg + '...') cfgNumber = 0 for cfg in data.configurations: cfgNumber = cfgNumber + 1 if len(data.configurations) > 1: - print('Checking ' + arg + ', config "' + cfg.name + '"...') + printStatus('Checking ' + arg + ', config "' + cfg.name + '"...') if cfgNumber == 1: misra_3_1(data.rawTokens)