diff options
author | Gabriel Remus <54900476+grlduarte@users.noreply.github.com> | 2022-06-24 12:18:08 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-25 00:18:08 +0900 |
commit | 4a0d669c0a49d2e156c0140be82cc56b8cd4305d (patch) | |
tree | 047552f049dd86d90c844bd886c465e7457c9c3e | |
parent | 0e99519500513ac6525f776722fb50a0197c54ce (diff) | |
download | ale-4a0d669c0a49d2e156c0140be82cc56b8cd4305d.zip |
Show warnings for `dart_analyze` linter (#4237)
-rw-r--r-- | ale_linters/dart/dart_analyze.vim | 13 | ||||
-rw-r--r-- | test/handler/test_dart_analyze_handler.vader | 11 |
2 files changed, 16 insertions, 8 deletions
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.', \ ]) |