Add --quiet flag to misra.py for cleaner output (#1254)

Output will still be given for style violations.

This allows the build process output to be smaller and cleaner,
making it easier to spot and address problems.
This commit is contained in:
Richard A. Smith 2018-05-21 15:46:58 -04:00 committed by Daniel Marjamäki
parent 5c15cd3981
commit 01cbadc6ed
1 changed files with 13 additions and 2 deletions

View File

@ -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)