diff options
author | ZyX <kp-pav@yandex.ru> | 2017-01-03 07:08:59 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-01-03 07:11:43 +0300 |
commit | 492c439c5499b1292088fbce2de01a98dcb80004 (patch) | |
tree | 3c959dfc4cf224a98d0660c5c5aa23e3f95effb2 /src/clint.py | |
parent | 287c69dd325fcbf5f550cffd1d09e08f266be762 (diff) | |
download | rneovim-492c439c5499b1292088fbce2de01a98dcb80004.tar.gz rneovim-492c439c5499b1292088fbce2de01a98dcb80004.tar.bz2 rneovim-492c439c5499b1292088fbce2de01a98dcb80004.zip |
clint: Check for misplaced brace at function start
Diffstat (limited to 'src/clint.py')
-rwxr-xr-x | src/clint.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/clint.py b/src/clint.py index d455fe03b9..97a30e2dfb 100755 --- a/src/clint.py +++ b/src/clint.py @@ -2576,6 +2576,28 @@ def CheckBraces(filename, clean_lines, linenum, error): '{ should almost always be at the end' ' of the previous line') + # Brace must appear after function signature, but on the *next* line + if Match(r'^(?:\w+(?: ?\*+)? )+\w+\(', line): + pos = line.find('(') + (endline, end_linenum, endpos) = CloseExpression( + clean_lines, linenum, pos) + if endline.endswith('{'): + error(filename, end_linenum, 'readability/braces', 5, + 'Brace starting function body must be placed on its own line') + else: + func_start_linenum = end_linenum + 1 + while not clean_lines.lines[func_start_linenum] == '{': + if not Match(r'^(?:\s*\b(?:FUNC_ATTR|REAL_FATTR)_\w+\b(?:\(\d+(, \d+)*\))?)+$', + clean_lines.lines[func_start_linenum]): + if clean_lines.lines[func_start_linenum].endswith('{'): + error(filename, func_start_linenum, + 'readability/braces', 5, + 'Brace starting function body must be placed ' + 'after the function signature') + break + else: + func_start_linenum += 1 + # 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. if Match(r'\s*else\s*', line): |