Mercurial > hg-stable
changeset 35324:e223c0438f89
check-code: allow tabs in heredoc
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 09 Dec 2017 00:39:15 +0900 |
parents | 1fe3c8296cfe |
children | 259feddc04e6 |
files | contrib/check-code.py tests/test-contrib-check-code.t |
diffstat | 2 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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),
--- a/tests/test-contrib-check-code.t Fri Dec 08 22:27:14 2017 +0800 +++ b/tests/test-contrib-check-code.t Sat Dec 09 00:39:15 2017 +0900 @@ -173,6 +173,17 @@ don't use old-style two-argument raise, use Exception(message) [1] + $ cat <<EOF > 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 <<EOF > """problematic rst text >