contrib/check-code.py
changeset 35324 e223c0438f89
parent 35260 91a7204631f1
child 35399 5feb782c7a95
--- a/contrib/check-code.py	Fri Dec 08 22:27:14 2017 +0800
+++ b/contrib/check-code.py	Sat Dec 09 00:39:15 2017 +0900
@@ -135,7 +135,6 @@
     (r'if\s*!', "don't use '!' to negate exit status"),
     (r'/dev/u?random', "don't use entropy, use /dev/zero"),
     (r'do\s*true;\s*done', "don't use true as loop body, use sleep 0"),
-    (r'^( *)\t', "don't use tabs to indent"),
     (r'sed (-e )?\'(\d+|/[^/]*/)i(?!\\\n)',
      "put a backslash-escaped newline after sed 'i' command"),
     (r'^diff *-\w*[uU].*$\n(^  \$ |^$)', "prefix diff -u/-U with cmp"),
@@ -225,6 +224,7 @@
   ]
 ]
 
+# transform plain test rules to unified test's
 for i in [0, 1]:
     for tp in testpats[i]:
         p = tp[0]
@@ -235,6 +235,11 @@
             p = r"^  [$>] .*(%s)" % p
         utestpats[i].append((p, m) + tp[2:])
 
+# don't transform the following rules:
+# "  > \t" and "  \t" should be allowed in unified tests
+testpats[0].append((r'^( *)\t', "don't use tabs to indent"))
+utestpats[0].append((r'^( ?)\t', "don't use tabs to indent"))
+
 utestfilters = [
     (r"<<(\S+)((.|\n)*?\n  > \1)", rephere),
     (r"( +)(#([^!][^\n]*\S)?)", repcomment),