Finetuned the coding style checker a little bit to allow groups of messages to be ignored (e.g. __IGNORE_WARNING_N10__ for all N10x warnings.

Fri, 05 May 2017 19:05:26 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 05 May 2017 19:05:26 +0200
changeset 5725
671561c52802
parent 5724
d1e0de43bc19
child 5726
e1dbd217214a

Finetuned the coding style checker a little bit to allow groups of messages to be ignored (e.g. __IGNORE_WARNING_N10__ for all N10x warnings.

Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py file | annotate | diff | comparison | revisions
--- 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:

eric ide

mercurial