mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Fix #4714 - Handle ruff garbage
When ruff outputs errors are invalid JSON text, handle that and stop ALE from throwing exceptions.
This commit is contained in:
43
test/handler/test_ruff_handler.vader
Normal file
43
test/handler/test_ruff_handler.vader
Normal file
@@ -0,0 +1,43 @@
|
||||
Before:
|
||||
runtime ale_linters/python/ruff.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(We should handle basic output of ruff correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 1,
|
||||
\ 'code': 'F821',
|
||||
\ 'type': 'W',
|
||||
\ 'end_col': 7,
|
||||
\ 'end_lnum': 2,
|
||||
\ 'text': 'Undefined name example',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#python#ruff#Handle(bufnr(''), [
|
||||
\ '{"cell":null,"code":"F821","end_location":{"column":8,"row":2},"filename":"/home/eduardo/Code/Python/test.py","fix":null,"location":{"column":1,"row":2},"message":"Undefined name example","noqa_row":2,"url":"https://docs.astral.sh/ruff/rules/undefined-name"}',
|
||||
\ ])
|
||||
|
||||
Execute(We should handle totally broken output from ruff):
|
||||
AssertEqual [], ale_linters#python#ruff#Handle(bufnr(''), ['ERROR: oh noes!'])
|
||||
|
||||
Execute(We should handle mixed error lines and JSON output from ruff):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 1,
|
||||
\ 'code': 'F821',
|
||||
\ 'type': 'W',
|
||||
\ 'end_col': 7,
|
||||
\ 'end_lnum': 2,
|
||||
\ 'text': 'Undefined name example',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#python#ruff#Handle(bufnr(''), [
|
||||
\ 'ERROR: oh noes!',
|
||||
\ '{"cell":null,"code":"F821","end_location":{"column":8,"row":2},"filename":"/home/eduardo/Code/Python/test.py","fix":null,"location":{"column":1,"row":2},"message":"Undefined name example","noqa_row":2,"url":"https://docs.astral.sh/ruff/rules/undefined-name"}',
|
||||
\ ])
|
||||
Reference in New Issue
Block a user