Dockerfile_lint checker: cleanup.

This commit is contained in:
LCD 47 2015-11-27 20:25:28 +02:00
parent 13456d5a71
commit 73dd785486
5 changed files with 51 additions and 27 deletions

View File

@ -54,10 +54,10 @@ compile their code or execute their script to find them.
At the time of this writing, syntastic has checking plugins for ActionScript, At the time of this writing, syntastic has checking plugins for ActionScript,
Ada, Ansible configurations, API Blueprint, AppleScript, AsciiDoc, ASM, Ada, Ansible configurations, API Blueprint, AppleScript, AsciiDoc, ASM,
BEMHTML, Bro, Bourne shell, C, C++, C#, Cabal, Chef, CoffeeScript, Coco, BEMHTML, Bro, Bourne shell, C, C++, C#, Cabal, Chef, CoffeeScript, Coco, Coq,
Coq, CSS, Cucumber, CUDA, D, Dart, DocBook, Dust, Elixir, Erlang, eRuby, CSS, Cucumber, CUDA, D, Dart, DocBook, Dockerfile, Dust, Elixir, Erlang,
Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell, Haxe, Handlebars, HSS, eRuby, Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell, Haxe, Handlebars,
HTML, Jade, Java, JavaScript, JSON, JSX, LESS, Lex, Limbo, LISP, LLVM HSS, HTML, Jade, Java, JavaScript, JSON, JSX, LESS, Lex, Limbo, LISP, LLVM
intermediate language, Lua, Markdown, MATLAB, Mercury, NASM, Nix, Objective-C, intermediate language, Lua, Markdown, MATLAB, Mercury, NASM, Nix, Objective-C,
Objective-C++, OCaml, Perl, Perl POD, PHP, gettext Portable Object, OS X and Objective-C++, OCaml, Perl, Perl POD, PHP, gettext Portable Object, OS X and
iOS property lists, Puppet, Python, QML, R, Racket, Relax NG, reStructuredText, iOS property lists, Puppet, Python, QML, R, Racket, Relax NG, reStructuredText,

View File

@ -62,26 +62,38 @@ endfunction " }}}2
function! syntastic#preprocess#dockerfile_lint(errors) abort " {{{2 function! syntastic#preprocess#dockerfile_lint(errors) abort " {{{2
let out = [] let out = []
let json = s:_decode_JSON(join(a:errors, '')) let json = s:_decode_JSON(join(a:errors, ''))
let data = json['error']['data'] + json['warn']['data'] + json['info']['data']
if type(json) == type({}) if type(json) == type({})
for e in data try
let type = toupper(e['level'][0]) let data = json['error']['data'] + json['warn']['data'] + json['info']['data']
let type = (type ==# 'I') ? 'W' : type for e in data
let line = has_key(e, 'line') ? e['line'] : 1 let type = toupper(e['level'][0])
let message = e['message'] if type ==# 'I'
if has_key(e, 'description') && e['description'] !=# 'None' let type = 'W'
let message = message . '. ' . e['description'] let style = 1
endif else
let style = 0
endif
let msg = let line = get(e, 'line', 1)
\ type . ':' . let message = e['message']
\ line . ':' . if has_key(e, 'description') && e['description'] !=# 'None'
\ message let message = message . '. ' . e['description']
call add(out, msg) endif
endfor
let msg =
\ type . ':' .
\ style . ':' .
\ line . ':' .
\ message
call add(out, msg)
endfor
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format')
let out = []
endtry
else else
call syntastic#log#warn('checker dockerfile/dockerfile-lint: unrecognized error format') call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format')
endif endif
return out return out
endfunction " }}}2 endfunction " }}}2

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START lockvar! g:_SYNTASTIC_START
endif endif
let g:_SYNTASTIC_VERSION = '3.7.0-37' let g:_SYNTASTIC_VERSION = '3.7.0-39'
lockvar g:_SYNTASTIC_VERSION lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1 " Sanity checks {{{1

View File

@ -30,6 +30,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'd': ['dmd'], \ 'd': ['dmd'],
\ 'dart': ['dartanalyzer'], \ 'dart': ['dartanalyzer'],
\ 'docbk': ['xmllint'], \ 'docbk': ['xmllint'],
\ 'dockerfile': ['dockerfile_lint'],
\ 'dustjs': ['swiffer'], \ 'dustjs': ['swiffer'],
\ 'elixir': [], \ 'elixir': [],
\ 'erlang': ['escript'], \ 'erlang': ['escript'],

View File

@ -1,6 +1,6 @@
"============================================================================ "============================================================================
"File: dockerfile_lint.vim "File: dockerfile_lint.vim
"Description: Syntax checking plugin for syntastic.vim using `dockerfile-lint` "Description: Syntax checking plugin for syntastic.vim using dockerfile-lint
" (https://github.com/projectatomic/dockerfile-lint). " (https://github.com/projectatomic/dockerfile-lint).
"Maintainer: Tim Carry <tim at pixelastic dot com> "Maintainer: Tim Carry <tim at pixelastic dot com>
"License: This program is free software. It comes without any warranty, "License: This program is free software. It comes without any warranty,
@ -10,7 +10,7 @@
" See http://sam.zoy.org/wtfpl/COPYING for more details. " See http://sam.zoy.org/wtfpl/COPYING for more details.
" "
"============================================================================ "============================================================================
"
if exists('g:loaded_syntastic_dockerfile_dockerfile_lint_checker') if exists('g:loaded_syntastic_dockerfile_dockerfile_lint_checker')
finish finish
endif endif
@ -21,15 +21,26 @@ set cpo&vim
function! SyntaxCheckers_dockerfile_dockerfile_lint_GetLocList() dict function! SyntaxCheckers_dockerfile_dockerfile_lint_GetLocList() dict
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'args': '--json -f' }) \ 'args_after': '-j',
\ 'fname_before': '-f' })
let errorformat = '%t:%l:%m' let errorformat = '%t:%n:%l:%m'
return SyntasticMake({ let loclist = SyntasticMake({
\ 'makeprg': makeprg, \ 'makeprg': makeprg,
\ 'errorformat': errorformat, \ 'errorformat': errorformat,
\ 'preprocess': 'dockerfile_lint',
\ 'defaults': {'bufnr': bufnr('')}, \ 'defaults': {'bufnr': bufnr('')},
\ 'preprocess': 'dockerfile_lint' }) \ 'returns': [0, 1] })
for e in loclist
if e['nr']
let e['subtype'] = 'Style'
endif
call remove(e, 'nr')
endfor
return loclist
endfunction endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({ call g:SyntasticRegistry.CreateAndRegisterChecker({