From patchwork Wed Jan 28 13:29:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 2, STABLE] check-code: detect (maybe) complicated processing inside "_()" From: Katsunori FUJIWARA X-Patchwork-Id: 7569 Message-Id: <7ec60cf08e322ccd3f5a.1422451787@juju> To: mercurial-devel@selenic.com Date: Wed, 28 Jan 2015 22:29:47 +0900 # HG changeset patch # User FUJIWARA Katsunori # Date 1422451379 -32400 # Wed Jan 28 22:22:59 2015 +0900 # Branch stable # Node ID 7ec60cf08e322ccd3f5ac17a8d443ff020d07407 # Parent 3da525e1db16adbc32734aa86a20cc7254724eb3 check-code: detect (maybe) complicated processing inside "_()" This patch can detect problematic "_()" usages like one fixed by previous patch. For simplicity, this patch focuses only on the 1st element inside "_()". It should be a string (starting with single-/double-quotation) or a symbol (for referring variable or invoking function). diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -211,6 +211,8 @@ pypats = [ (r'\s<>\s', '<> operator is not available in Python 3+, use !='), (r'^\s*\t', "don't use tabs"), (r'\S;\s*\n', "semicolon"), + (r'[^_]_\([ \t\n]*[^"\'\w \t\n]', + "don't put complicated expression inside _()"), (r'[^_]_\([ \t\n]*(?:"[^"]+"[ \t\n+]*)+%', "don't use % inside _()"), (r"[^_]_\([ \t\n]*(?:'[^']+'[ \t\n+]*)+%", "don't use % inside _()"), (r'(\w|\)),\w', "missing whitespace after ,"),