Complain about binary operators on the ends of lines

This commit is contained in:
w0rp 2019-02-10 11:43:48 +00:00
parent d072d2654c
commit 7a48750610
No known key found for this signature in database
GPG key ID: 0FC1ECAA8C81CD83
5 changed files with 26 additions and 14 deletions

View file

@ -101,8 +101,8 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort
if type(l:json) is v:t_dict if type(l:json) is v:t_dict
for l:key in keys(l:json) for l:key in keys(l:json)
if has_key(l:json[l:key], 'sorrows') && if has_key(l:json[l:key], 'sorrows')
\ has_key(l:json[l:key], 'worries') \&& has_key(l:json[l:key], 'worries')
if !empty(l:json[l:key]['sorrows']) if !empty(l:json[l:key]['sorrows'])
for l:dictionary in get(l:json[l:key], 'sorrows') for l:dictionary in get(l:json[l:key], 'sorrows')
for l:item in keys(l:dictionary) for l:item in keys(l:dictionary)

View file

@ -87,8 +87,8 @@ endfunction
" Skip sandbox error which is caused by directives " Skip sandbox error which is caused by directives
" because what we want is syntactic or semantic check. " because what we want is syntactic or semantic check.
function! s:Ignore(item) abort function! s:Ignore(item) abort
return a:item.type is# 'E' && return a:item.type is# 'E'
\ a:item.text =~# '\vNo permission to (call|directive|assert) sandboxed' \ && a:item.text =~# '\vNo permission to (call|directive|assert) sandboxed'
endfunction endfunction
call ale#linter#Define('prolog', { call ale#linter#Define('prolog', {

View file

@ -7,9 +7,10 @@ call ale#Set('python_bandit_use_global', get(g:, 'ale_use_global_executables', 0
call ale#Set('python_bandit_auto_pipenv', 0) call ale#Set('python_bandit_auto_pipenv', 0)
function! ale_linters#python#bandit#GetExecutable(buffer) abort function! ale_linters#python#bandit#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || if (
\ ale#Var(a:buffer, 'python_bandit_auto_pipenv')) \ ale#Var(a:buffer, 'python_auto_pipenv')
\ && ale#python#PipenvPresent(a:buffer) \ || ale#Var(a:buffer, 'python_bandit_auto_pipenv')
\) && ale#python#PipenvPresent(a:buffer)
return 'pipenv' return 'pipenv'
endif endif

View file

@ -53,9 +53,11 @@ function! ale#loclist_jumping#FindNearest(direction, wrap, ...) abort
\ l:search_item \ l:search_item
\) \)
if (l:filter is# 'any' || l:filter is# l:item.type) && if (l:filter is# 'any' || l:filter is# l:item.type)
\ (l:subtype_filter is# 'any' || \&& (
\ l:subtype_filter is# get(l:item, 'sub_type', '')) \ l:subtype_filter is# 'any'
\ || l:subtype_filter is# get(l:item, 'sub_type', '')
\)
if a:direction is# 'before' && l:cmp_value < 0 if a:direction is# 'before' && l:cmp_value < 0
return [l:item.lnum, l:item.col] return [l:item.lnum, l:item.col]
@ -71,9 +73,11 @@ function! ale#loclist_jumping#FindNearest(direction, wrap, ...) abort
" wrap around the list of warnings/errors " wrap around the list of warnings/errors
if a:wrap if a:wrap
for l:item in l:loclist for l:item in l:loclist
if (l:filter is# 'any' || l:filter is# l:item.type) && if (l:filter is# 'any' || l:filter is# l:item.type)
\ (l:subtype_filter is# 'any' || \&& (
\ l:subtype_filter is# get(l:item, 'sub_type', '')) \ l:subtype_filter is# 'any'
\ || l:subtype_filter is# get(l:item, 'sub_type', '')
\)
return [l:item.lnum, l:item.col] return [l:item.lnum, l:item.col]
endif endif
endfor endfor

View file

@ -11,6 +11,7 @@ import re
INDENTATION_RE = re.compile(r'^ *') INDENTATION_RE = re.compile(r'^ *')
COMMENT_LINE_RE = re.compile(r'^ *"') COMMENT_LINE_RE = re.compile(r'^ *"')
COMMAND_RE = re.compile(r'^ *([a-zA-Z\\]+)') COMMAND_RE = re.compile(r'^ *([a-zA-Z\\]+)')
OPERATOR_END_RE = re.compile(r'(&&|\|\||\+|-|\*\| /)$')
START_BLOCKS = set(['if', 'for', 'while', 'try', 'function']) START_BLOCKS = set(['if', 'for', 'while', 'try', 'function'])
END_BLOCKS = set(['endif', 'endfor', 'endwhile', 'endtry', 'endfunction']) END_BLOCKS = set(['endif', 'endfor', 'endwhile', 'endtry', 'endfunction'])
@ -70,7 +71,7 @@ def check_lines(line_iter):
if ( if (
previous_indentation_level is not None previous_indentation_level is not None
and indentation_level != previous_indentation_level and indentation_level != previous_indentation_level
and abs(indentation_level - previous_indentation_level) != 4 and abs(indentation_level - previous_indentation_level) != 4 # noqa
): ):
yield ( yield (
line_number, line_number,
@ -119,6 +120,12 @@ def check_lines(line_iter):
previous_line_blank = False previous_line_blank = False
previous_indentation_level = indentation_level previous_indentation_level = indentation_level
if OPERATOR_END_RE.search(line):
yield (
line_number,
'Put operators at the start of lines instead'
)
def main(): def main():
status = 0 status = 0