Mercurial > public > mercurial-scm > hg-stable
comparison contrib/check-code.py @ 11341:920a783e5f91
check-code: fix check for any/all function
The old check would only detect any/all at the beginning of a line.
The regexp was probably just modeled after the preceding regexp which
(correctly) finds the 'with' keyword at the beginning of a line.
We now complain about 'any(' and 'all(' anywhere in a line, unless it
is preceded by 'def'. This allows us to define our own compatibility
wrapper in util and use 'util.any(' in the code.
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Tue, 15 Jun 2010 09:51:52 +0200 |
parents | 0c0088881562 |
children | f325db39c8b9 |
comparison
equal
deleted
inserted
replaced
11340:938fefb57db5 | 11341:920a783e5f91 |
---|---|
90 # (r'in range\(', "use xrange"), | 90 # (r'in range\(', "use xrange"), |
91 # (r'^\s*print\s+', "avoid using print in core and extensions"), | 91 # (r'^\s*print\s+', "avoid using print in core and extensions"), |
92 (r'[\x80-\xff]', "non-ASCII character literal"), | 92 (r'[\x80-\xff]', "non-ASCII character literal"), |
93 (r'("\')\.format\(', "str.format() not available in Python 2.4"), | 93 (r'("\')\.format\(', "str.format() not available in Python 2.4"), |
94 (r'^\s*with\s+', "with not available in Python 2.4"), | 94 (r'^\s*with\s+', "with not available in Python 2.4"), |
95 (r'^\s*(any|all)\(', "any/all not available in Python 2.4"), | 95 (r'(?<!def)\s+(any|all)\(', "any/all not available in Python 2.4"), |
96 (r'if\s.*\selse', "if ... else form not available in Python 2.4"), | 96 (r'if\s.*\selse', "if ... else form not available in Python 2.4"), |
97 (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"), | 97 (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"), |
98 # (r'\s\s=', "gratuitous whitespace before ="), | 98 # (r'\s\s=', "gratuitous whitespace before ="), |
99 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator"), | 99 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', "missing whitespace around operator"), |
100 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s', "missing whitespace around operator"), | 100 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s', "missing whitespace around operator"), |