From 13cf982b776b3e40ccc9419efef432f9065b354b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 5 Aug 2018 20:36:21 +0200 Subject: [PATCH] some small *.py script cleanup (#1328) * added CLion project folder to .gitignore * adjusted project name in CMakeLists.txt * avoid warning when compiling "Debug" with Visual Studio via CMake There was a GCC-style compiler flag in the common flags in compileroptions.cmake which caused the following warning: cl : Command line warning D9002 : ignoring unknown option '-O0' * compileroptions.cmake: restored original formatting * some small *.py script cleanups --- addons/cert.py | 5 +++-- addons/cppcheckdata.py | 2 +- addons/misc.py | 2 +- addons/misra.py | 12 ++++++------ tools/compare-ast-clang-and-cppcheck.py | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/addons/cert.py b/addons/cert.py index 294fcbe30..5ae3b78cd 100755 --- a/addons/cert.py +++ b/addons/cert.py @@ -35,7 +35,7 @@ def isUnpackedStruct(token): if token.valueType is None: return False if token.valueType.typeScope is None: - return False; + return False if token.valueType.typeScope.type != "Struct": return False startToken = token.valueType.typeScope.bodyStart @@ -78,7 +78,8 @@ def getArgumentsRecursive(tok, arguments): getArgumentsRecursive(tok.astOperand1, arguments) getArgumentsRecursive(tok.astOperand2, arguments) else: - arguments.append(tok); + arguments.append(tok) + def getArguments(ftok): arguments = [] diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py index 9775f349d..87d168e0b 100755 --- a/addons/cppcheckdata.py +++ b/addons/cppcheckdata.py @@ -776,7 +776,7 @@ def reportError(template, callstack=(), severity='', message='', errorId='', sup :param template: format string, or 'gcc', 'vs' or 'edit'. :param callstack: e.g. [['file1.cpp',10],['file2.h','20'], ... ] :param severity: e.g. 'error', 'warning' ... - :param id: message ID. + :param errorId: message ID. :param message: message text. """ # expand predefined templates diff --git a/addons/misc.py b/addons/misc.py index ec53c99a8..64805ef60 100644 --- a/addons/misc.py +++ b/addons/misc.py @@ -39,7 +39,7 @@ def getArgumentsRecursive(tok, arguments): getArgumentsRecursive(tok.astOperand1, arguments) getArgumentsRecursive(tok.astOperand2, arguments) else: - arguments.append(tok); + arguments.append(tok) def getArguments(ftok): arguments = [] diff --git a/addons/misra.py b/addons/misra.py index 1bfc11cc0..022b644ad 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -299,7 +299,7 @@ def isFloatCounterInWhileLoop(whileToken): else: return False token = whileBodyStart - while (token != whileBodyStart.link): + while token != whileBodyStart.link: token = token.next for counterToken in counterTokens: if not counterToken.valueType or not counterToken.valueType.isFloat(): @@ -480,7 +480,7 @@ def isHexDigit(c): def isOctalDigit(c): - return (c >= '0' and c <= '7') + return c >= '0' and c <= '7' def isNoReturnScope(tok): @@ -591,7 +591,7 @@ def misra_5_2(data): else: reportError(variable2.nameToken, 5, 2) for innerscope in scopeVars[scope]["scopelist"]: - if (variable1.nameToken.str[:31] == innerscope.className[:31]): + if variable1.nameToken.str[:31] == innerscope.className[:31]: if int(variable1.nameToken.linenr) > int(innerscope.bodyStart.linenr): reportError(variable1.nameToken, 5, 2) else: @@ -600,7 +600,7 @@ def misra_5_2(data): continue for i, scopename1 in enumerate(scopeVars[scope]["scopelist"]): for scopename2 in scopeVars[scope]["scopelist"][i + 1:]: - if (scopename1.className[:31] == scopename2.className[:31]): + if scopename1.className[:31] == scopename2.className[:31]: if int(scopename1.bodyStart.linenr) > int(scopename2.bodyStart.linenr): reportError(scopename1.bodyStart, 5, 2) else: @@ -642,7 +642,7 @@ def misra_5_3(data): reportError(outerVar.nameToken, 5, 3) outerScope = outerScope.nestedIn for scope in data.scopes: - if (scope.className and innerVar.nameToken.str[:31] == scope.className[:31]): + if scope.className and innerVar.nameToken.str[:31] == scope.className[:31]: if int(innerVar.nameToken.linenr) > int(scope.bodyStart.linenr): reportError(innerVar.nameToken, 5, 3) else: @@ -656,7 +656,7 @@ def misra_5_3(data): reportError(innerScope.bodyStart, 5, 3) for e in enum: for scope in data.scopes: - if (scope.className and scope.className[:31] == e[:31]): + if scope.className and scope.className[:31] == e[:31]: reportError(scope.bodyStart, 5, 3) diff --git a/tools/compare-ast-clang-and-cppcheck.py b/tools/compare-ast-clang-and-cppcheck.py index 21adb681c..ad8d007c3 100644 --- a/tools/compare-ast-clang-and-cppcheck.py +++ b/tools/compare-ast-clang-and-cppcheck.py @@ -27,7 +27,7 @@ def clang_ast(sourcefile): while len(line)>1 and line[-1] in ' \r\n': line = line[:-1] if line.find('/usr/') > 0: - continue + continue if line.startswith('