diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -135,7 +135,6 @@ testpats = [ (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 @@ utestpats = [ ] ] +# 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 @@ for i in [0, 1]: 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), diff --git a/tests/test-contrib-check-code.t b/tests/test-contrib-check-code.t --- a/tests/test-contrib-check-code.t +++ b/tests/test-contrib-check-code.t @@ -173,6 +173,17 @@ don't use old-style two-argument raise, use Exception(message) [1] + $ cat < tab.t + > indent + > > heredoc + > EOF + $ "$check_code" tab.t + tab.t:1: + > indent + don't use tabs to indent + [1] + $ rm tab.t + $ cat > rst.py < """problematic rst text >