comparison contrib/check-code.py @ 29279:438caf194160

check-code: make repquote distinguish more characters for exact detection This patch makes repquote() distinguish more characters below, as a preparation for exact detection in subsequent patch. - "%" as "%" - "\\" as "b"(ackslash) - "*" as "A"(sterisk) - "+" as "P"(lus) - "-" as "M"(inus) Characters other than "%" don't use itself as replacement, because they are treated as special ones in regexp.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 31 May 2016 21:02:30 +0900
parents 5eda83fb09fc
children 12c97985ddeb
comparison
equal deleted inserted replaced
29278:5eda83fb09fc 29279:438caf194160
51 return re.compile(pat) 51 return re.compile(pat)
52 52
53 def repquote(m): 53 def repquote(m):
54 # check "rules depending on implementation of repquote()" in each 54 # check "rules depending on implementation of repquote()" in each
55 # patterns (especially pypats), before changing this function 55 # patterns (especially pypats), before changing this function
56 fixedmap = {' ': ' ', '\n': '\n', '.': 'p', ':': 'q'} 56 fixedmap = {' ': ' ', '\n': '\n', '.': 'p', ':': 'q',
57 '%': '%', '\\': 'b', '*': 'A', '+': 'P', '-': 'M'}
57 def encodechr(i): 58 def encodechr(i):
58 if i > 255: 59 if i > 255:
59 return 'u' 60 return 'u'
60 c = chr(i) 61 c = chr(i)
61 if c in fixedmap: 62 if c in fixedmap:
324 (r'^import cStringIO', "don't use cStringIO.StringIO, use util.stringio"), 325 (r'^import cStringIO', "don't use cStringIO.StringIO, use util.stringio"),
325 (r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"), 326 (r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"),
326 (r'\.next\(\)', "don't use .next(), use next(...)"), 327 (r'\.next\(\)', "don't use .next(), use next(...)"),
327 328
328 # rules depending on implementation of repquote() 329 # rules depending on implementation of repquote()
329 (r' x+[xpqo][\'"]\n\s+[\'"]x', 'string join across lines with no space'), 330 (r' x+[xpqo%APM][\'"]\n\s+[\'"]x',
331 'string join across lines with no space'),
330 (r'ui\.(status|progress|write|note|warn)\([\'\"]x', 332 (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
331 "missing _() in ui message (use () to hide false-positives)"), 333 "missing _() in ui message (use () to hide false-positives)"),
332 ], 334 ],
333 # warnings 335 # warnings
334 [ 336 [