misc.py: Make it possible to run this addon from cppcheck
This commit is contained in:
parent
a508b2abfd
commit
d2949adff1
|
@ -14,6 +14,7 @@ DEBUG = ('-debug' in sys.argv)
|
||||||
VERIFY = ('-verify' in sys.argv)
|
VERIFY = ('-verify' in sys.argv)
|
||||||
VERIFY_EXPECTED = []
|
VERIFY_EXPECTED = []
|
||||||
VERIFY_ACTUAL = []
|
VERIFY_ACTUAL = []
|
||||||
|
CLI = ('--cli' in sys.argv)
|
||||||
|
|
||||||
def reportError(token, severity, msg, id):
|
def reportError(token, severity, msg, id):
|
||||||
if id == 'debug' and DEBUG == False:
|
if id == 'debug' and DEBUG == False:
|
||||||
|
@ -21,8 +22,11 @@ def reportError(token, severity, msg, id):
|
||||||
if VERIFY:
|
if VERIFY:
|
||||||
VERIFY_ACTUAL.append(str(token.linenr) + ':' + id)
|
VERIFY_ACTUAL.append(str(token.linenr) + ':' + id)
|
||||||
else:
|
else:
|
||||||
sys.stderr.write(
|
msg = '[' + token.file + ':' + str(token.linenr) + ']: (' + severity + ') ' + msg + ' [misc-' + id + ']'
|
||||||
'[' + token.file + ':' + str(token.linenr) + '] (' + severity + '): ' + msg + ' [' + id + ']\n')
|
if CLI:
|
||||||
|
print(msg)
|
||||||
|
else:
|
||||||
|
sys.stderr.write(msg + '\n')
|
||||||
|
|
||||||
def simpleMatch(token, pattern):
|
def simpleMatch(token, pattern):
|
||||||
for p in pattern.split(' '):
|
for p in pattern.split(' '):
|
||||||
|
@ -136,7 +140,7 @@ def ellipsisStructArg(data):
|
||||||
break
|
break
|
||||||
|
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if arg in ['-debug', '-verify']:
|
if arg in ['-debug', '-verify', '--cli']:
|
||||||
continue
|
continue
|
||||||
print('Checking ' + arg + '...')
|
print('Checking ' + arg + '...')
|
||||||
data = cppcheckdata.parsedump(arg)
|
data = cppcheckdata.parsedump(arg)
|
||||||
|
|
Loading…
Reference in New Issue