[PATCH 2 of 2 STABLE] check-code: detect (maybe) complicated processing inside "_()"

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Jan 28 07:29:47 CST 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# 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 ,"),


More information about the Mercurial-devel mailing list