diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-04-21 09:23:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-21 09:23:07 +0100 |
commit | 20241c87ef9f033e2ac2f44f5bb99af358ab44b2 (patch) | |
tree | 537bc0e0174af27d4ab415708b24ae437a86ebf1 /ale_linters/cucumber/cucumber.vim | |
parent | 63bbb38c0ce9237b17acbfc29f192a0656c62677 (diff) | |
parent | 1e6651e0a0039185d63ebe4f26f04937e82207fb (diff) | |
download | ale-20241c87ef9f033e2ac2f44f5bb99af358ab44b2.zip |
Merge pull request #1511 from elebow/add-cucumber-checker
Add `cucumber` checker for Cucumber files
Diffstat (limited to 'ale_linters/cucumber/cucumber.vim')
-rw-r--r-- | ale_linters/cucumber/cucumber.vim | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ale_linters/cucumber/cucumber.vim b/ale_linters/cucumber/cucumber.vim new file mode 100644 index 00000000..6708d32f --- /dev/null +++ b/ale_linters/cucumber/cucumber.vim @@ -0,0 +1,45 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: Cucumber, a BDD test tool + +function! ale_linters#cucumber#cucumber#GetCommand(buffer) abort + let l:features_dir = ale#path#FindNearestDirectory(a:buffer, 'features') + + if !empty(l:features_dir) + let l:features_arg = '-r ' . ale#Escape(l:features_dir) + else + let l:features_arg = '' + endif + + return 'cucumber --dry-run --quiet --strict --format=json ' + \ . l:features_arg . ' %t' +endfunction + +function! ale_linters#cucumber#cucumber#Handle(buffer, lines) abort + try + let l:json = ale#util#FuzzyJSONDecode(a:lines, {})[0] + catch + return [] + endtry + + let l:output = [] + for l:element in get(l:json, 'elements', []) + for l:step in l:element['steps'] + if l:step['result']['status'] is# 'undefined' + call add(l:output, { + \ 'lnum': l:step['line'], + \ 'code': 'E', + \ 'text': 'Undefined step' + \}) + endif + endfor + endfor + + return l:output +endfunction + +call ale#linter#Define('cucumber', { +\ 'name': 'cucumber', +\ 'executable': 'cucumber', +\ 'command_callback': 'ale_linters#cucumber#cucumber#GetCommand', +\ 'callback': 'ale_linters#cucumber#cucumber#Handle' +\}) |