Checker d/dscanner: cleanup.

This commit is contained in:
LCD 47 2017-03-30 18:16:38 +03:00
parent c6f83efdd3
commit 75180daad7
4 changed files with 49 additions and 43 deletions

View File

@ -98,6 +98,35 @@ function! syntastic#preprocess#dockerfile_lint(errors) abort " {{{2
return out return out
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#dscanner(errors) abort " {{{2
let idx = 0
while idx < len(a:errors) && a:errors[idx][0] !=# '{'
let idx += 1
endwhile
let errs = s:_decode_JSON(join(a:errors[idx :], ''))
let out = []
if type(errs) == type({}) && has_key(errs, 'issues') && type(errs['issues']) == type([])
for issue in errs['issues']
try
call add(out,
\ issue['fileName'] . ':' .
\ issue['line'] . ':' .
\ issue['column'] . ':' .
\ issue['message'] . ' [' . issue['key'] . ']')
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker d/dscanner: unrecognized error item ' . string(issue))
let out = []
break
endtry
endfor
else
call syntastic#log#warn('checker d/dscanner: unrecognized error format (crashed checker?)')
endif
return out
endfunction " }}}2
function! syntastic#preprocess#flow(errors) abort " {{{2 function! syntastic#preprocess#flow(errors) abort " {{{2
let idx = 0 let idx = 0
while idx < len(a:errors) && a:errors[idx][0] !=# '{' while idx < len(a:errors) && a:errors[idx][0] !=# '{'
@ -424,21 +453,6 @@ function! syntastic#preprocess#validator(errors) abort " {{{2
return out return out
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#dscanner(errors) abort " {{{2
let startIndex = index(a:errors, '{')
let data = join(a:errors[startIndex:], '')
let errs = s:_decode_JSON(data)
let out = []
let issues = errs['issues']
for issue in issues
let msg = issue['fileName'] . ':' . issue['line'] . ':'
\ . issue['column'] . ':' . issue['message']
call add(out, msg)
endfor
return out
endfunction " }}}2
function! syntastic#preprocess#vint(errors) abort " {{{2 function! syntastic#preprocess#vint(errors) abort " {{{2
let errs = s:_decode_JSON(join(a:errors, '')) let errs = s:_decode_JSON(join(a:errors, ''))

View File

@ -1755,7 +1755,7 @@ SYNTAX CHECKERS FOR D *syntastic-checkers-d*
The following checkers are available for D (filetype "d"): The following checkers are available for D (filetype "d"):
1. DMD......................|syntastic-d-dmd| 1. DMD......................|syntastic-d-dmd|
1. D-Scanner................|syntastic-d-dscanner| 2. D-Scanner................|syntastic-d-dscanner|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
1. DMD *syntastic-d-dmd* 1. DMD *syntastic-d-dmd*
@ -1841,8 +1841,8 @@ executable.
Name: dscanner Name: dscanner
Maintainer: ANtlord Maintainer: ANtlord
"D-Scanner" is a tool for analyzing D source code (https://dlang.org/). "D-Scanner" is a tool for analyzing D source code (https://dlang.org/). See
See the manual for more information: the project's page at GitHub for more information:
https://github.com/Hackerpilot/Dscanner https://github.com/Hackerpilot/Dscanner

View File

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

View File

@ -1,7 +1,12 @@
"============================================================================ "============================================================================
"File: dscanner.vim "File: dscanner.vim
"Description: Syntax checking plugin for syntastic.vim "Description: Syntax checking plugin for syntastic
"Maintainer: ANtlord "Maintainer: ANtlord
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
" "
"============================================================================ "============================================================================
@ -10,40 +15,27 @@ if exists('g:loaded_syntastic_d_dscanner_checker')
endif endif
let g:loaded_syntastic_d_dscanner_checker = 1 let g:loaded_syntastic_d_dscanner_checker = 1
if !exists('g:syntastic_d_dscanner_sort')
let g:syntastic_d_dscanner_sort = 1
endif
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! SyntaxCheckers_d_dscanner_IsAvailable() dict
let exec_file = self.getExec()
let is_exec = executable(exec_file)
if !is_exec
call self.log('Syntastic: D-Scanner executable file not found.')
endif
return is_exec
endfunction
function! SyntaxCheckers_d_dscanner_GetLocList() dict function! SyntaxCheckers_d_dscanner_GetLocList() dict
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'args': '--report', \ 'args_after': '--report',
\ 'tail': '2>/dev/null', \ 'tail': '2>' . syntastic#util#DevNull() })
\ 'args_after': '' })
let errorformat = '%f:%l:%c:%m' let errorformat = '%f:%l:%c:%m'
let loclist = SyntasticMake({
return SyntasticMake({
\ 'makeprg': makeprg, \ 'makeprg': makeprg,
\ 'errorformat': errorformat, \ 'errorformat': errorformat,
\ 'preprocess': 'dscanner'}) \ 'preprocess': 'dscanner',
return loclist \ 'subtype': 'Style',
\ 'returns': [0] })
endfunction endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({ call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'd', \ 'filetype': 'd',
\ 'name': 'dscanner', \ 'name': 'dscanner' })
\ 'exec': 'dscanner' })
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo