diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -51,22 +51,20 @@ def compilere(pat, multiline=False): return re.compile(pat) def repquote(m): - fromc = '.:' - tochr = 'pq' + fixedmap = {'.': 'p', ':': 'q'} def encodechr(i): if i > 255: return 'u' c = chr(i) if c in ' \n': return c + if c in fixedmap: + return fixedmap[c] if c.isalpha(): return 'x' if c.isdigit(): return 'n' - try: - return tochr[fromc.find(c)] - except (ValueError, IndexError): - return 'o' + return 'o' t = m.group('text') tt = ''.join(encodechr(i) for i in xrange(256)) t = t.translate(tt) @@ -248,7 +246,7 @@ pypats = [ (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"), (r'\w\s=\s\s+\w', "gratuitous whitespace after ="), (r'.{81}', "line too long"), - (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'), + (r' x+[xpqo][\'"]\n\s+[\'"]x', 'string join across lines with no space'), (r'[^\n]\Z', "no trailing newline"), (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"), # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', 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 @@ -248,3 +248,27 @@ web templates > {desc|escape} warning: follow desc keyword with either firstline or websub [1] + +'string join across lines with no space' detection + + $ cat > stringjoin.py < foo = (' foo' + > 'bar foo.' + > 'bar foo:' + > 'bar foo@' + > 'bar') + > EOF + $ "$check_code" stringjoin.py + stringjoin.py:1: + > foo = (' foo' + string join across lines with no space + stringjoin.py:2: + > 'bar foo.' + string join across lines with no space + stringjoin.py:3: + > 'bar foo:' + string join across lines with no space + stringjoin.py:4: + > 'bar foo@' + string join across lines with no space + [1]