diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-04-13 08:56:31 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-04-13 08:56:31 -0400 |
commit | 69d74f588a885d42228b4ff83348283c36ed96a9 (patch) | |
tree | 70d0b0b69ac79d4735a63ea18437233e5ef4c3e5 /clint.py | |
parent | 982198143d3a6f5e9e4880b37206db6fbcb05c7c (diff) | |
parent | 4a6328a8eb7d2964f0290c4fc32eea31931d6114 (diff) | |
download | rneovim-69d74f588a885d42228b4ff83348283c36ed96a9.tar.gz rneovim-69d74f588a885d42228b4ff83348283c36ed96a9.tar.bz2 rneovim-69d74f588a885d42228b4ff83348283c36ed96a9.zip |
Merge pull request #4566 from ZyX-I/more-lint
Add more lint checks: space before asterisk and preincrement/predecrement
Diffstat (limited to 'clint.py')
-rwxr-xr-x | clint.py | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -191,6 +191,7 @@ _ERROR_CATEGORIES = [ 'readability/nul', 'readability/todo', 'readability/utf8', + 'readability/increment', 'runtime/arrays', 'runtime/int', 'runtime/invalid_increment', @@ -2291,6 +2292,11 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): # there's too little whitespace, we get concerned. It's hard to tell, # though, so we punt on this one for now. TODO. + match = Search(r'(?:[^ (*/![])+(?<!\+\+|--)\*', line) + if match: + error(filename, linenum, 'whitespace/operators', 2, + 'Missing space before asterisk in %s' % match.group(0)) + # You should always have whitespace around binary operators. # # Check <= and >= first to avoid false positives with < and >, then @@ -3194,6 +3200,23 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, error(filename, linenum, 'readability/bool', 4, 'Use %s instead of %s.' % (token.lower(), token)) + # Detect preincrement/predecrement + match = Match(r'^\s*(?:\+\+|--)', line) + if match: + error(filename, linenum, 'readability/increment', 5, + 'Do not use preincrement in statements, ' + 'use postincrement instead') + # Detect preincrement/predecrement in for(;; preincrement) + match = Search(r';\s*(\+\+|--)', line) + if match: + end_pos, end_depth = FindEndOfExpressionInLine(line, match.start(1), 1, + '(', ')') + expr = line[match.start(1):end_pos] + if end_depth == 0 and ';' not in expr and ' = ' not in expr: + error(filename, linenum, 'readability/increment', 4, + 'Do not use preincrement in statements, including ' + 'for(;; action)') + def ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, @@ -3484,6 +3507,7 @@ def main(): if __name__ == '__main__': main() +# vim: ts=4 sts=4 sw=4 # Ignore "too complex" warnings when using pymode. # pylama:ignore=C901 |