diff --git a/ale_linters/bitbake/oelint_adv.vim b/ale_linters/bitbake/oelint_adv.vim index e66125ad..f18d90d3 100644 --- a/ale_linters/bitbake/oelint_adv.vim +++ b/ale_linters/bitbake/oelint_adv.vim @@ -5,6 +5,14 @@ call ale#Set('bitbake_oelint_adv_executable', 'oelint-adv') call ale#Set('bitbake_oelint_adv_options', '') call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg') +function! ale_linters#bitbake#oelint_adv#StripAnsiCodes(line) abort + return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g') +endfunction + +function! ale_linters#bitbake#oelint_adv#RemoveBranch(line) abort + return substitute(a:line, ' \[branch:.*', '', 'g') +endfunction + function! ale_linters#bitbake#oelint_adv#Command(buffer) abort let l:config_file = ale#path#FindNearestFile(a:buffer, \ ale#Var(a:buffer, 'bitbake_oelint_adv_config')) @@ -22,25 +30,20 @@ function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': str2nr(l:match[2]), - \ 'type': l:match[3] is# 'error' - \ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'), - \ 'text': RemoveBranch(StripAnsiCodes(l:match[5])), - \ 'code': l:match[4] - \ }) + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:match[3] is# 'error' + \ ? 'E' + \ : (l:match[3] is# 'warning' ? 'W' : 'I'), + \ 'text': ale_linters#bitbake#oelint_adv#RemoveBranch( + \ ale_linters#bitbake#oelint_adv#StripAnsiCodes(l:match[5]) + \ ), + \ 'code': l:match[4], + \}) endfor return l:output endfunction -function! StripAnsiCodes(line) abort - return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g') -endfunction - -function! RemoveBranch(line) abort - return substitute(a:line, ' \[branch:.*', '', 'g') -endfunction - call ale#linter#Define('bitbake', { \ 'name': 'oelint_adv', \ 'output_stream': 'both', diff --git a/test/handler/test_bitbake_oelint_adv_handler.vader b/test/handler/test_bitbake_oelint_adv_handler.vader index d712aab6..8980fac3 100644 --- a/test/handler/test_bitbake_oelint_adv_handler.vader +++ b/test/handler/test_bitbake_oelint_adv_handler.vader @@ -47,4 +47,3 @@ Execute(The oelint_adv handler should handle warnings without branch message): \ '/meta-x/recipes-y/example/example_1.0.bb:1234:info:oelint.var.suggestedvar.BUGTRACKER:Variable ''BUGTRACKER'' should be set', \ 'example2_1.1.bb:17:error:oelint.var.mandatoryvar.DESCRIPTION:Variable ''DESCRIPTION'' should be set', \ ]) -