contrib/check-code.py
changeset 16705 c2d9ef43ff6c
parent 16704 1f3acc30bdfe
child 16965 91284af53508
--- a/contrib/check-code.py	Sun May 13 13:17:50 2012 +0200
+++ b/contrib/check-code.py	Sun May 13 13:18:06 2012 +0200
@@ -203,10 +203,10 @@
     (r'(?i)descendent', "the proper spelling is descendAnt"),
     (r'\.debug\(\_', "don't mark debug messages for translation"),
     (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"),
+    (r'^\s*except\s*:', "warning: naked except clause", r'#.*re-raises'),
   ],
   # warnings
   [
-    (r'^\s*except\s*:', "warning: naked except clause"),
     (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
      "warning: unwrapped ui message"),
   ]
@@ -355,7 +355,13 @@
 
         prelines = None
         errors = []
-        for p, msg in pats:
+        for pat in pats:
+            if len(pat) == 3:
+                p, msg, ignore = pat
+            else:
+                p, msg = pat
+                ignore = None
+
             # fix-up regexes for multiline searches
             po = p
             # \s doesn't match \n
@@ -386,6 +392,8 @@
                         print "Skipping %s for %s:%s (check-code -ignore)" % (
                             name, f, n)
                     continue
+                elif ignore and re.search(ignore, l, re.MULTILINE):
+                    continue
                 bd = ""
                 if blame:
                     bd = 'working directory'