From 6d0d05410a3406a773219b9d487b902b548e6cb1 Mon Sep 17 00:00:00 2001 From: ynonp Date: Thu, 15 Sep 2016 10:37:53 +0300 Subject: [PATCH 1/3] ADD rubocop linter --- ale_linters/ruby/rubocop.vim | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ale_linters/ruby/rubocop.vim diff --git a/ale_linters/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim new file mode 100644 index 0000000..e13309c --- /dev/null +++ b/ale_linters/ruby/rubocop.vim @@ -0,0 +1,46 @@ +if exists('g:loaded_ale_linters_ruby_rubocop') + finish +endif + +let g:loaded_ale_linters_ruby_rubocop = 1 + +function! ale_linters#ruby#rubocop#Handle(buffer, lines) + " Matches patterns line the following: + " + " :47:14: Missing trailing comma. [Warning/comma-dangle] + " :56:41: Missing semicolon. [Error/semi] + " let pattern = '.*_:\(\d\+\):\(\d\+\): \(.\) \(.\+\)' + let pattern = '\v_:(\d+):(\d+): (.): (.+)' + let output = [] + + for line in a:lines + let l:match = matchlist(line, pattern) + + if len(l:match) == 0 + continue + endif + + let text = l:match[4] + let type = l:match[3] + + " vcol is Needed to indicate that the column is a character. + call add(output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'vcol': 0, + \ 'col': l:match[2] + 0, + \ 'text': text, + \ 'type': type ==# 'C' ? 'E' : 'W', + \ 'nr': -1, + \}) + endfor + + return output +endfunction + +call ALEAddLinter('ruby', { +\ 'executable': 'rubocop', +\ 'command': 'rubocop --format emacs --stdin _', +\ 'callback': 'ale_linters#ruby#rubocop#Handle', +\}) + From 5180deb1d20b904d751c815c34cd93b210ae7115 Mon Sep 17 00:00:00 2001 From: ynonp Date: Thu, 15 Sep 2016 10:39:26 +0300 Subject: [PATCH 2/3] FIXED comments --- ale_linters/ruby/rubocop.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ale_linters/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim index e13309c..7ed91f4 100644 --- a/ale_linters/ruby/rubocop.vim +++ b/ale_linters/ruby/rubocop.vim @@ -7,9 +7,8 @@ let g:loaded_ale_linters_ruby_rubocop = 1 function! ale_linters#ruby#rubocop#Handle(buffer, lines) " Matches patterns line the following: " - " :47:14: Missing trailing comma. [Warning/comma-dangle] - " :56:41: Missing semicolon. [Error/semi] - " let pattern = '.*_:\(\d\+\):\(\d\+\): \(.\) \(.\+\)' + " /_:47:14: 83:29: C: Prefer single-quoted strings when you don't + " need string interpolation or special symbols. let pattern = '\v_:(\d+):(\d+): (.): (.+)' let output = [] From a1becad4902f732dceab4c2698439d3e99047ad3 Mon Sep 17 00:00:00 2001 From: ynonp Date: Thu, 15 Sep 2016 10:42:13 +0300 Subject: [PATCH 3/3] Add rubocop to readme file --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f85ae38..a5cda3a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ follow later. | -------- | ----- | | JavaScript | [eslint](http://eslint.org/) | | Python | [flake8](http://flake8.pycqa.org/en/latest/) | +| Ruby | [rubocop](https://github.com/bbatsov/rubocop) | If you would like to see support for more languages and tools, please [create an issue](https://github.com/w0rp/ale/issues)