diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-06-11 12:14:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-11 12:14:58 -0400 |
commit | f0c1a06792586d8373639ad2e9d34de6594cece3 (patch) | |
tree | 6612b88611deb097cabe19c0cfec48273a696423 /src/clint.py | |
parent | 290215364898fbd3a660be6c0642377c47398619 (diff) | |
parent | 244967bff918cbde43eea823c1bf0fa86d566623 (diff) | |
download | rneovim-f0c1a06792586d8373639ad2e9d34de6594cece3.tar.gz rneovim-f0c1a06792586d8373639ad2e9d34de6594cece3.tar.bz2 rneovim-f0c1a06792586d8373639ad2e9d34de6594cece3.zip |
Merge #4908 from ZyX-I/clint-checks-2
Add more clint checks
Diffstat (limited to 'src/clint.py')
-rwxr-xr-x | src/clint.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/clint.py b/src/clint.py index c19ba4b7ae..80e4c4ac39 100755 --- a/src/clint.py +++ b/src/clint.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# vim: set fileencoding=utf-8 # # Copyright (c) 2009 Google Inc. All rights reserved. # @@ -217,6 +218,8 @@ _ERROR_CATEGORIES = [ 'whitespace/semicolon', 'whitespace/tab', 'whitespace/todo', + 'whitespace/line_continuation', + 'whitespace/cast', ] # The default state of the category filter. This is overrided by the --filter= @@ -2499,6 +2502,27 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): error(filename, linenum, 'whitespace/braces', 5, 'Missing space before }') + if Search(r'\S {2,}\\$', line): + error(filename, linenum, 'whitespace/line_continuation', 5, + 'Too many spaces before \\, line continuation character must be ' + 'preceded by exactly one space. For “blank lines” ' + 'it is preferred to use the same amount of spaces as preceding ' + 'indent') + + if Match(r'^ +#', line): + error(filename, linenum, 'whitespace/indent', 5, + 'Must not indent preprocessor directives, use 1-space indent ' + 'after the hash') + + cast_line = re.sub(r'^# *define +\w+\([^)]*\)', '', line) + match = Search(r'\((?:const )?(?:struct )?[a-zA-Z_]\w*(?: *\*(?:const)?)*\)' + r' +' + r'-?(?:\*+|&)?(?:\w+|\+\+|--|\()', cast_line) + if match and line[0] == ' ': + error(filename, linenum, 'whitespace/cast', 2, + 'Should leave no spaces after a cast: {!r}'.format( + match.group(0))) + def GetPreviousNonBlankLine(clean_lines, linenum): """Return the most recent non-blank line and its line number. |