mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-16 01:07:06 +08:00
#810 - Handle output which is not JSON in many linters
This commit is contained in:
@@ -4,9 +4,7 @@ Execute(The crystal handler should parse lines correctly and add the column if i
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'bufnr': 255,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'unexpected token: EOF'
|
||||
\ }
|
||||
\ ],
|
||||
|
||||
@@ -75,9 +75,11 @@ Execute(The ember-template-lint handler should handle template parsing error cor
|
||||
|
||||
Execute(The ember-template-lint handler should handle no lint errors/warnings):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ],
|
||||
\ [],
|
||||
\ ale_linters#handlebars#embertemplatelint#Handle(347, [])
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#handlebars#embertemplatelint#Handle(347, ['{}'])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
Before:
|
||||
" Switch to the test rails directory.
|
||||
let b:path = getcwd()
|
||||
silent! cd /testplugin/test/handler
|
||||
cd ../ruby_fixtures/valid_rails_app/app/models
|
||||
call ale#test#SetDirectory('/testplugin/test/handler')
|
||||
cd ..
|
||||
|
||||
runtime ale_linters/ruby/rails_best_practices.vim
|
||||
runtime ale_linters/ruby/rails_best_practices.vim
|
||||
|
||||
After:
|
||||
" Switch back to whatever directory it was that we started on.
|
||||
silent! 'cd ' . fnameescape(b:path)
|
||||
unlet! b:path
|
||||
|
||||
call ale#linter#Reset()
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The rails_best_practices handler should parse JSON correctly):
|
||||
silent file! thing.rb
|
||||
call ale#test#SetFilename('ruby_fixtures/valid_rails_app/app/models/thing.rb')
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
@@ -34,11 +29,11 @@ Execute(The rails_best_practices handler should parse JSON correctly):
|
||||
\ '{',
|
||||
\ '"message": "use local variable",',
|
||||
\ '"line_number": "5",',
|
||||
\ '"filename": "/testplugin/test/ruby_fixtures/valid_rails_app/app/models/thing.rb"',
|
||||
\ '"filename": "' . g:dir . '/ruby_fixtures/valid_rails_app/app/models/thing.rb"',
|
||||
\ '},{',
|
||||
\ '"message": "other advice",',
|
||||
\ '"line_number": "10",',
|
||||
\ '"filename": "/testplugin/test/ruby_fixtures/valid_rails_app/app/models/thing.rb"',
|
||||
\ '"filename": "' . g:dir . '/ruby_fixtures/valid_rails_app/app/models/thing.rb"',
|
||||
\ '}',
|
||||
\ ']'
|
||||
\ ])
|
||||
@@ -48,3 +43,10 @@ Execute(The rails_best_practices handler should parse JSON correctly when there
|
||||
\ [],
|
||||
\ ale_linters#ruby#rails_best_practices#Handle(347, [
|
||||
\ ])
|
||||
|
||||
Execute(The rails_best_practices handler should handle garbage output):
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#ruby#rails_best_practices#Handle(347, [
|
||||
\ 'No such command in 2.4.1 of ruby',
|
||||
\ ])
|
||||
|
||||
@@ -2,68 +2,75 @@ Before:
|
||||
runtime ale_linters/ruby/reek.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The reek handler should parse JSON correctly, with only context enabled):
|
||||
let g:ale_ruby_reek_show_context = 1
|
||||
let g:ale_ruby_reek_show_wiki_link = 0
|
||||
let g:ale_ruby_reek_show_context = 1
|
||||
let g:ale_ruby_reek_show_wiki_link = 0
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'text': 'Rule1: Context#method violates rule number one',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 34,
|
||||
\ 'text': 'Rule2: Context#method violates rule number two',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 56,
|
||||
\ 'text': 'Rule2: Context#method violates rule number two',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"},{"context":"Context#method","lines":[34, 56],"message":"violates rule number two","smell_type":"Rule2","source":"/home/user/file.rb","name":"bad code","count":2,"wiki_link":"https://example.com/Rule1.md"}]'
|
||||
\ ])
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'text': 'Rule1: Context#method violates rule number one',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 34,
|
||||
\ 'text': 'Rule2: Context#method violates rule number two',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 56,
|
||||
\ 'text': 'Rule2: Context#method violates rule number two',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"},{"context":"Context#method","lines":[34, 56],"message":"violates rule number two","smell_type":"Rule2","source":"/home/user/file.rb","name":"bad code","count":2,"wiki_link":"https://example.com/Rule1.md"}]'
|
||||
\ ])
|
||||
|
||||
Execute(The reek handler should parse JSON correctly, with no context or wiki links):
|
||||
let g:ale_ruby_reek_show_context = 0
|
||||
let g:ale_ruby_reek_show_wiki_link = 0
|
||||
let g:ale_ruby_reek_show_context = 0
|
||||
let g:ale_ruby_reek_show_wiki_link = 0
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'text': 'Rule1: violates rule number one',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"}]'
|
||||
\ ])
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'text': 'Rule1: violates rule number one',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"}]'
|
||||
\ ])
|
||||
|
||||
Execute(The reek handler should parse JSON correctly, with both context and wiki links):
|
||||
let g:ale_ruby_reek_show_context = 1
|
||||
let g:ale_ruby_reek_show_wiki_link = 1
|
||||
let g:ale_ruby_reek_show_context = 1
|
||||
let g:ale_ruby_reek_show_wiki_link = 1
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'text': 'Rule1: Context#method violates rule number one [https://example.com/Rule1.md]',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"}]'
|
||||
\ ])
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'text': 'Rule1: Context#method violates rule number one [https://example.com/Rule1.md]',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ '[{"context":"Context#method","lines":[12],"message":"violates rule number one","smell_type":"Rule1","source":"/home/user/file.rb","parameter":"bad parameter","wiki_link":"https://example.com/Rule1.md"}]'
|
||||
\ ])
|
||||
|
||||
Execute(The reek handler should parse JSON correctly when there is no output from reek):
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ ])
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ ])
|
||||
|
||||
Execute(The reek handler should handle garbage output):
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#ruby#reek#Handle(347, [
|
||||
\ 'No such command in 2.4.1 of ruby',
|
||||
\ ])
|
||||
|
||||
Reference in New Issue
Block a user