Mercurial > hg
changeset 29278:5eda83fb09fc
check-code: centralize rules depending on implementation of repquote
This decreases the cost of checking which regexp should be adjusted at
change of repquote().
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 31 May 2016 21:02:30 +0900 |
parents | 79a11506803f |
children | 438caf194160 |
files | contrib/check-code.py |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/check-code.py Tue May 31 21:02:30 2016 +0900 +++ b/contrib/check-code.py Tue May 31 21:02:30 2016 +0900 @@ -51,6 +51,8 @@ return re.compile(pat) def repquote(m): + # check "rules depending on implementation of repquote()" in each + # patterns (especially pypats), before changing this function fixedmap = {' ': ' ', '\n': '\n', '.': 'p', ':': 'q'} def encodechr(i): if i > 255: @@ -244,7 +246,6 @@ (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+[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*=', @@ -311,8 +312,6 @@ (r'^\s*except\s([^\(,]+|\([^\)]+\))\s*,', 'legacy exception syntax; use "as" instead of ","'), (r':\n( )*( ){1,3}[^ ]', "must indent 4 spaces"), - (r'ui\.(status|progress|write|note|warn)\([\'\"]x', - "missing _() in ui message (use () to hide false-positives)"), (r'release\(.*wlock, .*lock\)', "wrong lock release order"), (r'\b__bool__\b', "__bool__ should be __nonzero__ in Python 2"), (r'os\.path\.join\(.*, *(""|\'\')\)', @@ -325,9 +324,15 @@ (r'^import cStringIO', "don't use cStringIO.StringIO, use util.stringio"), (r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"), (r'\.next\(\)', "don't use .next(), use next(...)"), + + # rules depending on implementation of repquote() + (r' x+[xpqo][\'"]\n\s+[\'"]x', 'string join across lines with no space'), + (r'ui\.(status|progress|write|note|warn)\([\'\"]x', + "missing _() in ui message (use () to hide false-positives)"), ], # warnings [ + # rules depending on implementation of repquote() (r'(^| )pp +xxxxqq[ \n][^\n]', "add two newlines after '.. note::'"), ] ] @@ -372,9 +377,13 @@ (r'^\s*#import\b', "use only #include in standard C code"), (r'strcpy\(', "don't use strcpy, use strlcpy or memcpy"), (r'strcat\(', "don't use strcat"), + + # rules depending on implementation of repquote() ], # warnings - [] + [ + # rules depending on implementation of repquote() + ] ] cfilters = [