mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-30 08:04:31 +08:00
Add a fixer for Python for automatically adding blank lines before control statements
This commit is contained in:
85
test/fixers/test_python_add_blank_lines_fixer.vader
Normal file
85
test/fixers/test_python_add_blank_lines_fixer.vader
Normal file
@@ -0,0 +1,85 @@
|
||||
Before:
|
||||
Save g:ale_fixers
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
Given python(Some Python without blank lines):
|
||||
def foo():
|
||||
return 1
|
||||
|
||||
|
||||
def bar():
|
||||
return 1
|
||||
return 4
|
||||
|
||||
|
||||
def bar():
|
||||
if x:
|
||||
pass
|
||||
for l in x:
|
||||
pass
|
||||
for l in x:
|
||||
pass
|
||||
break
|
||||
continue
|
||||
elif x:
|
||||
pass
|
||||
while x:
|
||||
pass
|
||||
while x:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
if x:
|
||||
pass
|
||||
elif x:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
|
||||
Execute(Blank lines should be added appropriately):
|
||||
let g:ale_fixers = {'python': ['ale#handlers#python#AddLinesBeforeControlStatements']}
|
||||
ALEFix
|
||||
|
||||
Expect python(Newlines should be added):
|
||||
def foo():
|
||||
return 1
|
||||
|
||||
|
||||
def bar():
|
||||
return 1
|
||||
|
||||
return 4
|
||||
|
||||
|
||||
def bar():
|
||||
if x:
|
||||
pass
|
||||
|
||||
for l in x:
|
||||
pass
|
||||
|
||||
for l in x:
|
||||
pass
|
||||
|
||||
break
|
||||
|
||||
continue
|
||||
elif x:
|
||||
pass
|
||||
|
||||
while x:
|
||||
pass
|
||||
|
||||
while x:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
|
||||
if x:
|
||||
pass
|
||||
elif x:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
Reference in New Issue
Block a user