diff --git a/ale_linters/dart/dart_analyze.vim b/ale_linters/dart/dart_analyze.vim index a00162d8..7d67c31c 100644 --- a/ale_linters/dart/dart_analyze.vim +++ b/ale_linters/dart/dart_analyze.vim @@ -4,15 +4,16 @@ call ale#Set('dart_analyze_executable', 'dart') function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort - let l:pattern = '\v^ ([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$' + let l:pattern = '\v([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) + let [l:type, l:filename, l:lnum, l:col, l:message, l:code] = l:match[1:6] call add(l:output, { - \ 'type': l:match[1] is# 'error' ? 'E' : 'W', - \ 'text': l:match[6] . ': ' . l:match[5], - \ 'lnum': str2nr(l:match[3]), - \ 'col': str2nr(l:match[4]), + \ 'type': l:type is# 'error' ? 'E' : l:type is# 'info' ? 'I' : 'W', + \ 'text': l:code . ': ' . l:message, + \ 'lnum': str2nr(l:lnum), + \ 'col': str2nr(l:col), \}) endfor @@ -22,7 +23,7 @@ endfunction call ale#linter#Define('dart', { \ 'name': 'dart_analyze', \ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')}, -\ 'command': '%e analyze %s', +\ 'command': '%e analyze --fatal-infos %s', \ 'callback': 'ale_linters#dart#dart_analyze#Handle', \ 'lint_file': 1, \}) diff --git a/test/handler/test_dart_analyze_handler.vader b/test/handler/test_dart_analyze_handler.vader index b3f20fb8..f167582c 100644 --- a/test/handler/test_dart_analyze_handler.vader +++ b/test/handler/test_dart_analyze_handler.vader @@ -19,10 +19,17 @@ Execute(Basic problems should be parsed correctly): \ 'lnum': 2, \ 'col': 16, \ }, + \ { + \ 'type': 'I', + \ 'text': 'dead_code: Dead code. Try removing the code, or fixing the code before it so that it can be reached.', + \ 'lnum': 8, + \ 'col': 3, + \ }, \ ], \ ale_linters#dart#dart_analyze#Handle(bufnr(''), [ \ 'Analyzing main.dart...', \ ' error - main.dart:5:1 - Expected to find ''}'' - expected_token', - \ ' warning - main.dart:2:16 - A value of type ''String'' can''t be assigned to a variable of type ''int'' - invalid_assignment', - \ '1 error and 1 warning found.', + \ 'warning - main.dart:2:16 - A value of type ''String'' can''t be assigned to a variable of type ''int'' - invalid_assignment', + \ ' info - main.dart:8:3 - Dead code. Try removing the code, or fixing the code before it so that it can be reached. - dead_code', + \ '3 issues found.', \ ])