diff -r d1e0de43bc19 -r 671561c52802 Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py --- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Fri May 05 19:00:39 2017 +0200 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Fri May 05 19:05:26 2017 +0200 @@ -106,6 +106,31 @@ return flags +def ignoreCode(code, lineFlags): + """ + Function to check, if the given code should be ignored as per line flags. + + @param code error code to be checked + @type str + @param lineFlags list of line flags to check against + @type list of str + """ + if lineFlags: + + if "__IGNORE_WARNING__" in lineFlags: + # ignore all warning codes + return True + + for flag in lineFlags: + # check individual warning code + if flag.startswith("__IGNORE_WARNING_"): + ignoredCode = flag[2:-2].rsplit("_", 1)[-1] + if code.startswith(ignoredCode): + return True + + return False + + def codeStyleCheck(filename, source, args): """ Do the code style check and/ or fix found errors. @@ -305,8 +330,7 @@ flagsLine=True) except IndexError: pass - if "__IGNORE_WARNING__" not in lineFlags and \ - "__IGNORE_WARNING_{0}__".format(code) not in lineFlags: + if not ignoreCode(code, lineFlags): if fixer: res, msg, id_ = fixer.fixIssue(lineno, position, text) if res == -1: