aboutsummaryrefslogtreecommitdiff
path: root/src/clint.py
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-01-03 06:54:40 +0300
committerZyX <kp-pav@yandex.ru>2017-01-03 07:11:43 +0300
commit287c69dd325fcbf5f550cffd1d09e08f266be762 (patch)
tree831f0616f8d0952f195658751c0260aebe9eda60 /src/clint.py
parentefe1476d4293170496f0e933a4d3c955f0559b03 (diff)
downloadrneovim-287c69dd325fcbf5f550cffd1d09e08f266be762.tar.gz
rneovim-287c69dd325fcbf5f550cffd1d09e08f266be762.tar.bz2
rneovim-287c69dd325fcbf5f550cffd1d09e08f266be762.zip
clint: Enable check for `{` positioned at the start of the line correctly
For some reason that was incorrectly hidden by “file is *not* \*.c or \*.h file” check.
Diffstat (limited to 'src/clint.py')
-rwxr-xr-xsrc/clint.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/clint.py b/src/clint.py
index efc5f18378..d455fe03b9 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -2560,22 +2560,21 @@ def CheckBraces(filename, clean_lines, linenum, error):
line = clean_lines.elided[linenum] # get rid of comments and strings
- if not (filename.endswith('.c') or filename.endswith('.h')):
- if Match(r'\s*{\s*$', line):
- # We allow an open brace to start a line in the case where someone
- # is using braces in a block to explicitly create a new scope, which
- # is commonly used to control the lifetime of stack-allocated
- # variables. Braces are also used for brace initializers inside
- # function calls. We don't detect this perfectly: we just don't
- # complain if the last non-whitespace character on the previous
- # non-blank line is ',', ';', ':', '(', '{', or '}', or if the
- # previous line starts a preprocessor block.
- prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0]
- if (not Search(r'[,;:}{(]\s*$', prevline) and
- not Match(r'\s*#', prevline)):
- error(filename, linenum, 'whitespace/braces', 4,
- '{ should almost always be at the end'
- ' of the previous line')
+ if Match(r'\s+{\s*$', line):
+ # We allow an open brace to start a line in the case where someone
+ # is using braces in a block to explicitly create a new scope, which
+ # is commonly used to control the lifetime of stack-allocated
+ # variables. Braces are also used for brace initializers inside
+ # function calls. We don't detect this perfectly: we just don't
+ # complain if the last non-whitespace character on the previous
+ # non-blank line is ',', ';', ':', '(', '{', or '}', or if the
+ # previous line starts a preprocessor block.
+ prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0]
+ if (not Search(r'[,;:}{(]\s*$', prevline) and
+ not Match(r'\s*#', prevline)):
+ error(filename, linenum, 'whitespace/braces', 4,
+ '{ should almost always be at the end'
+ ' of the previous line')
# An else clause should be on the same line as the preceding closing brace.
# If there is no preceding closing brace, there should be one.