[PATCH 6 of 6] check-code: Check for "if (not) rev:"

Simon Heimberg simohe at besonet.ch
Sun Sep 11 10:46:26 CDT 2011


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1315426558 -7200
# Node ID bbcdb6b8b707347deb77759bc2acc6fd1e5d01be
# Parent  55954d156e189cf5424d44b32905e0eff0c7b8f2
check-code: Check for "if (not) rev:"

and optional for similar constructs (not when a plural noun)

diff -r 55954d156e18 -r bbcdb6b8b707 contrib/check-code.py
--- a/contrib/check-code.py	Son Sep 11 17:34:54 2011 +0200
+++ b/contrib/check-code.py	Mit Sep 07 22:15:58 2011 +0200
@@ -184,6 +184,8 @@
      "always assign an opened file to a variable, and close it afterwards"),
     (r'(?i)descendent', "the proper spelling is descendAnt"),
     (r'\.debug\(\_', "don't mark debug messages for translation"),
+    (r'\bif +(not)? +rev([a-rt-z][a-z])? *:(?!.*#.*\b((never|ignores?) +0|is (str|byte).*)\b)',
+     "rev could be 0, 'if' will fail in this case"),
   ],
   # warnings
   [
@@ -191,6 +193,8 @@
     (r'^\s*except:$', "warning: naked except clause"),
     (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
      "warning: unwrapped ui message"),
+    (r'\bif +(not)? +\w{3,}[^s]\b *:(?!.*#.*\b((never|ignores?) +0|is [a-z]{3,}))',
+     "warning: variable could be 0, 'if' will fail in this case"),
   ]
 ]
 


More information about the Mercurial-devel mailing list