Mercurial > hg
comparison contrib/check-code.py @ 34384:b52f22d9afa5
contrib: add a check to check-code to ban superfluous pass statements
These have annoyed me for a long time, and I'm tired of commenting on
them in reviews. I'm sorry for how complicated the regular expression
is, but I was too lazy to go crack open pylint's code and add the
check there.
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 29 Sep 2017 11:55:44 -0400 |
parents | ba6e14f9a2d8 |
children | b332c01247d8 |
comparison
equal
deleted
inserted
replaced
34383:ab687e06fe02 | 34384:b52f22d9afa5 |
---|---|
255 (r"[^_]_\([ \t\n]*(?:'[^']+'[ \t\n+]*)+%", "don't use % inside _()"), | 255 (r"[^_]_\([ \t\n]*(?:'[^']+'[ \t\n+]*)+%", "don't use % inside _()"), |
256 (r'(\w|\)),\w', "missing whitespace after ,"), | 256 (r'(\w|\)),\w', "missing whitespace after ,"), |
257 (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"), | 257 (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"), |
258 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"), | 258 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"), |
259 (r'\w\s=\s\s+\w', "gratuitous whitespace after ="), | 259 (r'\w\s=\s\s+\w', "gratuitous whitespace after ="), |
260 (( | |
261 # a line ending with a colon, potentially with trailing comments | |
262 r':([ \t]*#[^\n]*)?\n' | |
263 # one that is not a pass and not only a comment | |
264 r'(?P<indent>[ \t]+)[^#][^\n]+\n' | |
265 # more lines at the same indent level | |
266 r'((?P=indent)[^\n]+\n)*' | |
267 # a pass at the same indent level, which is bogus | |
268 r'(?P=indent)pass[ \t\n#]' | |
269 ), 'omit superfluous pass'), | |
260 (r'.{81}', "line too long"), | 270 (r'.{81}', "line too long"), |
261 (r'[^\n]\Z', "no trailing newline"), | 271 (r'[^\n]\Z', "no trailing newline"), |
262 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"), | 272 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"), |
263 # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', | 273 # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', |
264 # "don't use underbars in identifiers"), | 274 # "don't use underbars in identifiers"), |