summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-19 01:08:20 +0000
committerw0rp <devw0rp@gmail.com>2017-11-19 01:08:20 +0000
commit01b2971d0432d6d25af0c592b4e0b2fdc7adcf7d (patch)
tree30a140041081c759bdf4e7219dba2516adb6b483
parent7123f7236b5415c29f1b48c01d2528f71c457be2 (diff)
downloadale-01b2971d0432d6d25af0c592b4e0b2fdc7adcf7d.zip
#852 - Capture error codes for slim-lint
-rw-r--r--ale_linters/slim/slimlint.vim13
-rw-r--r--test/handler/test_slim_handler.vader6
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',
\ },
\ {