Merge pull request #3225 from markeganfuller/puppet_parser_error_at_end

Handling for puppet parser error at end of input.
This commit is contained in:
Horacio Sanson 2020-07-15 21:08:42 +09:00 committed by GitHub
commit 54aeeec97f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -9,13 +9,14 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort
" Error: Could not parse for environment production: Syntax error at '='; expected '}' at /root/puppetcode/modules/pancakes/manifests/init.pp:5"
" Error: Could not parse for environment production: Syntax error at 'parameter1' (file: /tmp/modules/mariadb/manifests/slave.pp, line: 4, column: 5)
" Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11)
let l:pattern = '^Error:\%(.*:\)\? \(.\+\) \((file:\|at\) .\+\.pp\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)'
" Error: Could not parse for environment production: Syntax error at end of input (file: /tmp/modules/bob/manifests/init.pp)
let l:pattern = '^Error:\%(.*:\)\? \(.\+\) \((file:\|at\) .\+\.pp\(\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)\|)$\)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[4] + 0,
\ 'col': l:match[6] + 0,
\ 'lnum': l:match[5] + 0,
\ 'col': l:match[7] + 0,
\ 'text': l:match[1],
\})
endfor

View File

@ -63,3 +63,15 @@ Execute(The puppet handler should correctly parse errors that are reported befor
\ ale_linters#puppet#puppet#Handle(255, [
\ "Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11)",
\ ])
Execute(The puppet handler should parse lines when end of input is the location):
AssertEqual
\ [
\ {
\ 'lnum': 0,
\ 'col': 0,
\ 'text': "Syntax error at end of input"
\ },
\ ],
\ ale_linters#puppet#puppet#Handle(255, [
\ "Error: Could not parse for environment production: Syntax error at end of input (file: /tmp//modules/test/manifests/init.pp)",
\ ])