Mercurial > public > mercurial-scm > hg
diff tests/test-check-code.t @ 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 | a61ed1c2d7a7 |
children | c26464ce0781 |
line wrap: on
line diff
--- a/tests/test-check-code.t Wed Apr 16 03:05:00 2014 +0900 +++ b/tests/test-check-code.t Wed Apr 16 03:05:00 2014 +0900 @@ -255,3 +255,32 @@ warning: add two newlines after '.. note::' [1] + $ cat > ./map-inside-gettext.py <<EOF + > print _("map inside gettext %s" % v) + > + > print _("concatenating " " by " " space %s" % v) + > print _("concatenating " + " by " + " '+' %s" % v) + > + > print _("maping operation in different line %s" + > % v) + > + > print _( + > "leading spaces inside of '(' %s" % v) + > EOF + $ "$check_code" ./map-inside-gettext.py + ./map-inside-gettext.py:1: + > print _("map inside gettext %s" % v) + don't use % inside _() + ./map-inside-gettext.py:3: + > print _("concatenating " " by " " space %s" % v) + don't use % inside _() + ./map-inside-gettext.py:4: + > print _("concatenating " + " by " + " '+' %s" % v) + don't use % inside _() + ./map-inside-gettext.py:6: + > print _("maping operation in different line %s" + don't use % inside _() + ./map-inside-gettext.py:9: + > print _( + don't use % inside _() + [1]