Mercurial > hg
comparison contrib/check-code.py @ 21097:e8ef59b351c3
check-code: detect "% inside _()" when there are leading whitespaces
Before this patch, "contrib/check-code.py" can't detect "% inside _()"
correctly, when there are leading whitespaces before the format
string, like below:
_(
"format string %s" % v)
This patch adds regexp pattern "[ \t\n]*" before the pattern matching
against the format string.
"[\s\n]" can't be used in this purpose, because "\s" is automatically
replaced with "[ \t]" by "_preparepats()" and "\s" in "[]" causes
nested "[]" unexpectedly.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 16 Apr 2014 03:05:00 +0900 |
parents | 6500a2eebee8 |
children | 4840abc83970 |
comparison
equal
deleted
inserted
replaced
21096:a45ed365904a | 21097:e8ef59b351c3 |
---|---|
205 'dict-from-generator'), | 205 'dict-from-generator'), |
206 (r'\.has_key\b', "dict.has_key is not available in Python 3+"), | 206 (r'\.has_key\b', "dict.has_key is not available in Python 3+"), |
207 (r'\s<>\s', '<> operator is not available in Python 3+, use !='), | 207 (r'\s<>\s', '<> operator is not available in Python 3+, use !='), |
208 (r'^\s*\t', "don't use tabs"), | 208 (r'^\s*\t', "don't use tabs"), |
209 (r'\S;\s*\n', "semicolon"), | 209 (r'\S;\s*\n', "semicolon"), |
210 (r'[^_]_\((?:"[^"]+"[ \t\n+]*)+%', "don't use % inside _()"), | 210 (r'[^_]_\([ \t\n]*(?:"[^"]+"[ \t\n+]*)+%', "don't use % inside _()"), |
211 (r"[^_]_\((?:'[^']+'[ \t\n+]*)+%", "don't use % inside _()"), | 211 (r"[^_]_\([ \t\n]*(?:'[^']+'[ \t\n+]*)+%", "don't use % inside _()"), |
212 (r'(\w|\)),\w', "missing whitespace after ,"), | 212 (r'(\w|\)),\w', "missing whitespace after ,"), |
213 (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"), | 213 (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"), |
214 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"), | 214 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"), |
215 (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n' | 215 (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n' |
216 r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Python 2.4'), | 216 r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Python 2.4'), |