mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 13:14:29 +08:00
Update oelint pattern (#5016)
* Update oelint pattern * Handle optional branch output
This commit is contained in:
@@ -17,7 +17,7 @@ function! ale_linters#bitbake#oelint_adv#Command(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort
|
function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort
|
||||||
let l:pattern = '\v^(.+):(.+):(.+):(.+):(.+)$'
|
let l:pattern = '\v^(.{-}):(.{-}):(.{-}):(.{-}):(.{-})$'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
@@ -25,7 +25,7 @@ function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort
|
|||||||
\ 'lnum': str2nr(l:match[2]),
|
\ 'lnum': str2nr(l:match[2]),
|
||||||
\ 'type': l:match[3] is# 'error'
|
\ 'type': l:match[3] is# 'error'
|
||||||
\ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'),
|
\ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'),
|
||||||
\ 'text': StripAnsiCodes(l:match[5]),
|
\ 'text': RemoveBranch(StripAnsiCodes(l:match[5])),
|
||||||
\ 'code': l:match[4]
|
\ 'code': l:match[4]
|
||||||
\ })
|
\ })
|
||||||
endfor
|
endfor
|
||||||
@@ -37,6 +37,10 @@ function! StripAnsiCodes(line) abort
|
|||||||
return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g')
|
return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! RemoveBranch(line) abort
|
||||||
|
return substitute(a:line, ' \[branch:.*', '', 'g')
|
||||||
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('bitbake', {
|
call ale#linter#Define('bitbake', {
|
||||||
\ 'name': 'oelint_adv',
|
\ 'name': 'oelint_adv',
|
||||||
\ 'output_stream': 'both',
|
\ 'output_stream': 'both',
|
||||||
|
|||||||
@@ -7,6 +7,27 @@ After:
|
|||||||
call ale#linter#Reset()
|
call ale#linter#Reset()
|
||||||
|
|
||||||
Execute(The oelint_adv handler should handle warnings):
|
Execute(The oelint_adv handler should handle warnings):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 1234,
|
||||||
|
\ 'type': 'I',
|
||||||
|
\ 'code': 'oelint.var.suggestedvar.BUGTRACKER',
|
||||||
|
\ 'text': 'Variable ''BUGTRACKER'' should be set',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 17,
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'code': 'oelint.var.mandatoryvar.DESCRIPTION',
|
||||||
|
\ 'text': 'Variable ''DESCRIPTION'' should be set',
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#bitbake#oelint_adv#Handle(1, [
|
||||||
|
\ '/meta-x/recipes-y/example/example_1.0.bb:1234:info:oelint.var.suggestedvar.BUGTRACKER:Variable ''BUGTRACKER'' should be set [branch:true]',
|
||||||
|
\ '[31mexample2_1.1.bb:17:error:oelint.var.mandatoryvar.DESCRIPTION:Variable ''DESCRIPTION'' should be set[0m [branch:true]',
|
||||||
|
\ ])
|
||||||
|
|
||||||
|
Execute(The oelint_adv handler should handle warnings without branch message):
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [
|
||||||
\ {
|
\ {
|
||||||
@@ -26,3 +47,4 @@ Execute(The oelint_adv handler should handle warnings):
|
|||||||
\ '/meta-x/recipes-y/example/example_1.0.bb:1234:info:oelint.var.suggestedvar.BUGTRACKER:Variable ''BUGTRACKER'' should be set',
|
\ '/meta-x/recipes-y/example/example_1.0.bb:1234:info:oelint.var.suggestedvar.BUGTRACKER:Variable ''BUGTRACKER'' should be set',
|
||||||
\ '[31mexample2_1.1.bb:17:error:oelint.var.mandatoryvar.DESCRIPTION:Variable ''DESCRIPTION'' should be set[0m',
|
\ '[31mexample2_1.1.bb:17:error:oelint.var.mandatoryvar.DESCRIPTION:Variable ''DESCRIPTION'' should be set[0m',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user