All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Eddie Lebow https://github.com/elebow
2 " Description: Brakeman, a static analyzer for Rails security
4 call ale#Set('ruby_brakeman_options', '')
5 call ale#Set('ruby_brakeman_executable', 'brakeman')
6 call ale#Set('ruby_brakeman_options', '')
8 function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
10 let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
11 let l:sep = has('win32') ? '\' : '/'
12 " Brakeman always outputs paths relative to the Rails app root
13 let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
15 for l:warning in get(l:json, 'warnings', [])
16 let l:text = l:warning.warning_type . ' ' . l:warning.message . ' (' . l:warning.confidence . ')'
17 let l:line = l:warning.line != v:null ? l:warning.line : 1
20 \ 'filename': l:rails_root . l:sep . l:warning.file,
30 function! ale_linters#ruby#brakeman#GetCommand(buffer) abort
31 let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
33 if l:rails_root is? ''
37 let l:executable = ale#Var(a:buffer, 'ruby_brakeman_executable')
39 return ale#ruby#EscapeExecutable(l:executable, 'brakeman')
41 \ . ale#Var(a:buffer, 'ruby_brakeman_options')
42 \ . ' -p ' . ale#Escape(l:rails_root)
45 call ale#linter#Define('ruby', {
47 \ 'executable': {b -> ale#Var(b, 'ruby_brakeman_executable')},
48 \ 'command': function('ale_linters#ruby#brakeman#GetCommand'),
49 \ 'callback': 'ale_linters#ruby#brakeman#Handle',