comparison contrib/check-code.py @ 10412:5326800d6937

check-code: import some pylint checks
author Matt Mackall <mpm@selenic.com>
date Tue, 09 Feb 2010 13:53:24 -0600
parents 3aa35db5e38c
children 63a9bfad50ff
comparison
equal deleted inserted replaced
10411:af4c42ec19ed 10412:5326800d6937
58 (r"<<(\S+)((.|\n)*?\n\1)", rephere), 58 (r"<<(\S+)((.|\n)*?\n\1)", rephere),
59 ] 59 ]
60 60
61 pypats = [ 61 pypats = [
62 (r'^\s*\t', "don't use tabs"), 62 (r'^\s*\t', "don't use tabs"),
63 (r'(\S\s+|^\s+)\n', "trailing whitespace"), 63 (r'\S;\s*\n', "semicolon"),
64 (r'\w,\w', "missing whitespace after ,"), 64 (r'\w,\w', "missing whitespace after ,"),
65 (r'\w[+/*\-<>]\w', "missing whitespace in expression"), 65 (r'\w[+/*\-<>]\w', "missing whitespace in expression"),
66 (r'^\s+\w+=\w+[^,)]$', "missing whitespace in assignment"), 66 (r'^\s+\w+=\w+[^,)]$', "missing whitespace in assignment"),
67 (r'.{85}', "line too long"), 67 (r'.{85}', "line too long"),
68 (r'[^\n]\Z', "no trailing newline"), 68 (r'[^\n]\Z', "no trailing newline"),
71 (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+', 71 (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+',
72 "linebreak after :"), 72 "linebreak after :"),
73 (r'class\s[^(]:', "old-style class, use class foo(object)"), 73 (r'class\s[^(]:', "old-style class, use class foo(object)"),
74 (r'^\s+del\(', "del isn't a function"), 74 (r'^\s+del\(', "del isn't a function"),
75 (r'^\s+except\(', "except isn't a function"), 75 (r'^\s+except\(', "except isn't a function"),
76 (r',]', "unneeded trailing ',' in list"),
76 # (r'class\s[A-Z][^\(]*\((?!Exception)', 77 # (r'class\s[A-Z][^\(]*\((?!Exception)',
77 # "don't capitalize non-exception classes"), 78 # "don't capitalize non-exception classes"),
78 # (r'in range\(', "use xrange"), 79 # (r'in range\(', "use xrange"),
79 # (r'^\s*print\s+', "avoid using print in core and extensions"), 80 # (r'^\s*print\s+', "avoid using print in core and extensions"),
80 (r'[\x80-\xff]', "non-ASCII character literal"), 81 (r'[\x80-\xff]', "non-ASCII character literal"),
81 (r'("\')\.format\(', "str.format() not available in Python 2.4"), 82 (r'("\')\.format\(', "str.format() not available in Python 2.4"),
82 (r'^\s*with\s+', "with not available in Python 2.4"), 83 (r'^\s*with\s+', "with not available in Python 2.4"),
83 (r'if\s.*\selse', "if ... else form not available in Python 2.4"), 84 (r'if\s.*\selse', "if ... else form not available in Python 2.4"),
84 (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"), 85 (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"),
85 # (r'\s\s=', "gratuitous whitespace before ="), 86 # (r'\s\s=', "gratuitous whitespace before ="),
86 (r'\S(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator") 87 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator"),
88 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s', "missing whitespace around operator"),
89 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator"),
90 (r'[^+=*!<>&| -](\s=|=\s)[^= ]', "wrong whitespace around ="),
87 ] 91 ]
88 92
89 pyfilters = [ 93 pyfilters = [
90 (r"""(''')(([^']|\\'|'{1,2}(?!'))*)'''""", repquote), 94 (r"""(''')(([^']|\\'|'{1,2}(?!'))*)'''""", repquote),
91 (r'''(""")(([^"]|\\"|"{1,2}(?!"))*)"""''', repquote), 95 (r'''(""")(([^"]|\\"|"{1,2}(?!"))*)"""''', repquote),