puppet: extract the puppet errorformat generation code into a function

This commit is contained in:
Martin Grenfell 2012-10-12 10:54:28 +01:00
parent 7b51216924
commit d210940339

View File

@ -78,25 +78,27 @@ function! s:getPuppetMakeprg()
return makeprg
endfunction
function! s:getPuppetEfm()
"some versions of puppet (e.g. 2.7.10) output the message below if there
"are any syntax errors
let errorformat = '%-Gerr: Try ''puppet help parser validate'' for usage,'
let errorformat .= 'err: Could not parse for environment %*[a-z]: %m at %f:%l'
"Puppet 3.0.0 changes this from "err:" to "Error:"
"reset errorformat in that case
if SyntasticIsVersionAtLeast(s:PuppetVersion(), [3,0,0])
let errorformat = '%-GError: Try ''puppet help parser validate'' for usage,'
let errorformat .= 'Error: Could not parse for environment %*[a-z]: %m at %f:%l'
endif
return errorformat
endfunction
function! SyntaxCheckers_puppet_GetLocList()
let errors = []
if !g:syntastic_puppet_validate_disable
let makeprg = s:getPuppetMakeprg()
"some versions of puppet (e.g. 2.7.10) output the message below if there
"are any syntax errors
let errorformat = '%-Gerr: Try ''puppet help parser validate'' for usage,'
let errorformat .= 'err: Could not parse for environment %*[a-z]: %m at %f:%l'
"Puppet 3.0.0 changes this from "err:" to "Error:"
"reset errorformat in that case
if SyntasticIsVersionAtLeast(s:PuppetVersion(), [3,0,0])
let errorformat = '%-GError: Try ''puppet help parser validate'' for usage,'
let errorformat .= 'Error: Could not parse for environment %*[a-z]: %m at %f:%l'
endif
let errors = errors + SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
let errors = errors + SyntasticMake({ 'makeprg': s:getPuppetMakeprg(), 'errorformat': s:getPuppetEfm() })
endif
if !g:syntastic_puppet_lint_disable