Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 02dbc64

Browse files
committed
New syntax checker for Ruby: rubocop.
1 parent 6f214cb commit 02dbc64

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

syntax_checkers/ruby/rubocop.vim

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"============================================================================
2+
"File: rubocop.vim
3+
"Description: Syntax checking plugin for syntastic.vim
4+
"Maintainer: Recai Oktaş <roktas@bil.omu.edu.tr>
5+
"License: This program is free software. It comes without any warranty,
6+
" to the extent permitted by applicable law. You can redistribute
7+
" it and/or modify it under the terms of the Do What The Fuck You
8+
" Want To Public License, Version 2, as published by Sam Hocevar.
9+
" See http://sam.zoy.org/wtfpl/COPYING for more details.
10+
"
11+
"============================================================================
12+
"
13+
" In order to use rubocop with the default ruby checker (mri):
14+
" let g:syntastic_ruby_checkers = ['mri', 'rubocop']
15+
16+
if exists("g:loaded_syntastic_ruby_rubocop_checker")
17+
finish
18+
endif
19+
let g:loaded_syntastic_ruby_rubocop_checker=1
20+
21+
function! SyntaxCheckers_ruby_rubocop_IsAvailable()
22+
return executable('rubocop')
23+
endfunction
24+
25+
function! SyntaxCheckers_ruby_rubocop_GetLocList()
26+
let makeprg = syntastic#makeprg#build({
27+
\ 'exe': 'rubocop',
28+
\ 'args': '--emacs --silent',
29+
\ 'subchecker': 'rubocop' })
30+
31+
let errorformat = '%f:%l:\ %t:\ %m'
32+
33+
let loclist = SyntasticMake({
34+
\ 'makeprg': makeprg,
35+
\ 'errorformat': errorformat,
36+
\ 'subtype': 'Style'})
37+
38+
" convert rubocop severities to error types recognized by syntastic
39+
for n in range(len(loclist))
40+
if loclist[n]['type'] == 'F'
41+
let loclist[n]['type'] = 'E'
42+
elseif loclist[n]['type'] != 'W' || loclist[n]['type'] != 'E'
43+
let loclist[n]['type'] = 'W'
44+
endif
45+
endfor
46+
47+
return loclist
48+
endfunction
49+
50+
call g:SyntasticRegistry.CreateAndRegisterChecker({
51+
\ 'filetype': 'ruby',
52+
\ 'name': 'rubocop'})

0 commit comments

Comments
 (0)