From 01b2971d0432d6d25af0c592b4e0b2fdc7adcf7d Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 19 Nov 2017 01:08:20 +0000 Subject: [PATCH] #852 - Capture error codes for slim-lint --- ale_linters/slim/slimlint.vim | 13 +++++++++++-- test/handler/test_slim_handler.vader | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ale_linters/slim/slimlint.vim b/ale_linters/slim/slimlint.vim index bb62c731..00c6b26c 100644 --- a/ale_linters/slim/slimlint.vim +++ b/ale_linters/slim/slimlint.vim @@ -28,11 +28,20 @@ function! ale_linters#slim#slimlint#Handle(buffer, lines) abort let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { + let l:item = { \ 'lnum': l:match[1] + 0, \ 'type': l:match[2], \ 'text': l:match[3] - \}) + \} + + let l:code_match = matchlist(l:item.text, '\v^([^:]+): (.+)$') + + if !empty(l:code_match) + let l:item.code = l:code_match[1] + let l:item.text = l:code_match[2] + endif + + call add(l:output, l:item) endfor return l:output diff --git a/test/handler/test_slim_handler.vader b/test/handler/test_slim_handler.vader index e8b6dcd6..bfd29f3a 100644 --- a/test/handler/test_slim_handler.vader +++ b/test/handler/test_slim_handler.vader @@ -11,12 +11,14 @@ Execute(The slim handler should parse lines correctly): \ [ \ { \ 'lnum': 1, - \ 'text': 'RedundantDiv: `div` is redundant when class attribute shortcut is present', + \ 'text': '`div` is redundant when class attribute shortcut is present', + \ 'code': 'RedundantDiv', \ 'type': 'W', \ }, \ { \ 'lnum': 2, - \ 'text': 'LineLength: Line is too long. [136/80]', + \ 'text': 'Line is too long. [136/80]', + \ 'code': 'LineLength', \ 'type': 'W', \ }, \ {