summaryrefslogtreecommitdiff
path: root/ale_linters/ruby
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2019-10-07 19:17:55 +0100
committerGitHub <noreply@github.com>2019-10-07 19:17:55 +0100
commit32b784219b91a99fb05a78825ce64c5a4f98f253 (patch)
treea597bd6a3a3d00671c25d976f93dc348b6df6f2e /ale_linters/ruby
parenta486aa1d24294c5b14c8b2763a3b5ffdc39d0739 (diff)
parent8aa1578605f88e237f2fc0307f176bd7171eb23e (diff)
downloadale-32b784219b91a99fb05a78825ce64c5a4f98f253.zip
Merge pull request #2694 from elebow/add-ruby-debride
Add ruby debride (closes #2471)
Diffstat (limited to 'ale_linters/ruby')
-rw-r--r--ale_linters/ruby/debride.vim42
1 files changed, 42 insertions, 0 deletions
diff --git a/ale_linters/ruby/debride.vim b/ale_linters/ruby/debride.vim
new file mode 100644
index 00000000..0a45644e
--- /dev/null
+++ b/ale_linters/ruby/debride.vim
@@ -0,0 +1,42 @@
+" Author: Eddie Lebow https://github.com/elebow
+" Description: debride, a dead method detector for Ruby files
+
+call ale#Set('ruby_debride_executable', 'debride')
+call ale#Set('ruby_debride_options', '')
+
+function! ale_linters#ruby#debride#GetCommand(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'ruby_debride_executable')
+
+ return ale#handlers#ruby#EscapeExecutable(l:executable, 'debride')
+ \ . ale#Var(a:buffer, 'ruby_debride_options')
+ \ . ' %s'
+endfunction
+
+function! ale_linters#ruby#debride#HandleOutput(buffer, lines) abort
+ let l:output = []
+
+ for l:line in a:lines
+ if l:line !~# '^ '
+ continue
+ endif
+
+ let l:elements = split(l:line)
+ let l:method_name = l:elements[0]
+ let l:lnum = split(l:elements[1], ':')[1]
+
+ call add(l:output, {
+ \ 'lnum': 0 + l:lnum,
+ \ 'text': 'Possible unused method: ' . l:method_name,
+ \ 'type': 'W',
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('ruby', {
+\ 'name': 'debride',
+\ 'executable': {b -> ale#Var(b, 'ruby_debride_executable')},
+\ 'command': function('ale_linters#ruby#debride#GetCommand'),
+\ 'callback': 'ale_linters#ruby#debride#HandleOutput',
+\})