mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 05:04:28 +08:00
Update erlang format for OTP24 (#3823)
Erlang's erlc error format includes the column in OTP24. See https://blog.erlang.org/My-OTP-24-Highlights/#column-number-in-warnings-and-errors
This commit is contained in:
committed by
GitHub
parent
1893abdb19
commit
a6a8131306
@@ -25,7 +25,7 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
|
|||||||
" error.erl:4: variable 'B' is unbound
|
" error.erl:4: variable 'B' is unbound
|
||||||
" error.erl:3: Warning: function main/0 is unused
|
" error.erl:3: Warning: function main/0 is unused
|
||||||
" error.erl:4: Warning: variable 'A' is unused
|
" error.erl:4: Warning: variable 'A' is unused
|
||||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (Warning: )?(.+)$'
|
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+:)? (Warning: )?(.+)$'
|
||||||
|
|
||||||
" parse_transforms are a special case. The error message does not indicate a location:
|
" parse_transforms are a special case. The error message does not indicate a location:
|
||||||
" error.erl: undefined parse transform 'some_parse_transform'
|
" error.erl: undefined parse transform 'some_parse_transform'
|
||||||
@@ -65,8 +65,8 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let l:line = l:match[2]
|
let l:line = l:match[2]
|
||||||
let l:warning_or_text = l:match[3]
|
let l:warning_or_text = l:match[4]
|
||||||
let l:text = l:match[4]
|
let l:text = l:match[5]
|
||||||
|
|
||||||
" If this file is a header .hrl, ignore the following expected messages:
|
" If this file is a header .hrl, ignore the following expected messages:
|
||||||
" - 'no module definition'
|
" - 'no module definition'
|
||||||
|
|||||||
@@ -38,3 +38,25 @@ Execute(The command should accept configured options.):
|
|||||||
\ g:matched,
|
\ g:matched,
|
||||||
\ -1,
|
\ -1,
|
||||||
\ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
|
\ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
|
||||||
|
|
||||||
|
Execute(Linter should recognize OTP23 format.):
|
||||||
|
let g:lines = ["t.erl:6: only association operators '=>' are allowed in map construction"]
|
||||||
|
let g:output_text = ale_linters#erlang#erlc#Handle(bufnr(''), g:lines)[0].text
|
||||||
|
|
||||||
|
let g:expected = "only association operators '=>' are allowed in map construction"
|
||||||
|
AssertEqual
|
||||||
|
\ g:output_text,
|
||||||
|
\ g:expected,
|
||||||
|
\ 'Command error: expected [' . g:output_text . '] to match [' . g:expected . ']'
|
||||||
|
|
||||||
|
Execute(Linter should recognize OTP24 format.):
|
||||||
|
let g:lines = ["t.erl:6:16: only association operators '=>' are allowed in map construction",
|
||||||
|
\ "% 6| #{ a => A, b := B }.",
|
||||||
|
\ "% | ^"]
|
||||||
|
let g:output_text = ale_linters#erlang#erlc#Handle(bufnr(''), g:lines)[0].text
|
||||||
|
|
||||||
|
let g:expected = "only association operators '=>' are allowed in map construction"
|
||||||
|
AssertEqual
|
||||||
|
\ g:output_text,
|
||||||
|
\ g:expected,
|
||||||
|
\ 'Command error: expected [' . g:output_text . '] to match [' . g:expected . ']'
|
||||||
|
|||||||
Reference in New Issue
Block a user