From 85e0bd33141a05216848e525b3e86b6698aa38cd Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Tue, 5 Dec 2017 16:02:15 -0300 Subject: [PATCH] Extract error code from message --- ale_linters/solidity/solhint.vim | 5 +++-- test/handler/test_solhint_handler.vader | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ale_linters/solidity/solhint.vim b/ale_linters/solidity/solhint.vim index cab2c18..519fd49 100644 --- a/ale_linters/solidity/solhint.vim +++ b/ale_linters/solidity/solhint.vim @@ -5,7 +5,7 @@ function! ale_linters#solidity#solhint#Handle(buffer, lines) abort " Matches patterns like the following: " /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars) - let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*)$' + let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -14,7 +14,8 @@ function! ale_linters#solidity#solhint#Handle(buffer, lines) abort \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 0, \ 'text': l:match[4], - \ 'type': l:isError ? 'E' : 'W' + \ 'code': l:match[5], + \ 'type': l:isError ? 'E' : 'W', \}) endfor diff --git a/test/handler/test_solhint_handler.vader b/test/handler/test_solhint_handler.vader index 43e3505..a3ed5d5 100644 --- a/test/handler/test_solhint_handler.vader +++ b/test/handler/test_solhint_handler.vader @@ -10,37 +10,43 @@ Execute(The vint handler should parse error messages correctly): \ { \ 'lnum': 1, \ 'col': 17, - \ 'text': 'Compiler version must be fixed (compiler-fixed)', + \ 'text': 'Compiler version must be fixed', + \ 'code': 'compiler-fixed', \ 'type': 'W', \ }, \ { \ 'lnum': 4, \ 'col': 8, - \ 'text': 'Use double quotes for string literals (quotes)', + \ 'text': 'Use double quotes for string literals', + \ 'code': 'quotes', \ 'type': 'E', \ }, \ { \ 'lnum': 5, \ 'col': 8, - \ 'text': 'Use double quotes for string literals (quotes)', + \ 'text': 'Use double quotes for string literals', + \ 'code': 'quotes', \ 'type': 'E', \ }, \ { \ 'lnum': 13, \ 'col': 3, - \ 'text': 'Expected indentation of 4 spaces but found 2 (indent)', + \ 'text': 'Expected indentation of 4 spaces but found 2', + \ 'code': 'indent', \ 'type': 'E', \ }, \ { \ 'lnum': 14, \ 'col': 3, - \ 'text': 'Expected indentation of 4 spaces but found 2 (indent)', + \ 'text': 'Expected indentation of 4 spaces but found 2', + \ 'code': 'indent', \ 'type': 'E', \ }, \ { \ 'lnum': 47, \ 'col': 3, - \ 'text': 'Function order is incorrect, public function can not go after internal function. (func-order)', + \ 'text': 'Function order is incorrect, public function can not go after internal function.', + \ 'code': 'func-order', \ 'type': 'E', \ }, \ ],