mirror of
https://github.com/dense-analysis/ale
synced 2024-12-26 16:12:40 +00:00
Merge pull request #1133 from nicwest/linter-clj-joker
add joker handler for clojure
This commit is contained in:
commit
1f4f19cbd4
@ -81,6 +81,7 @@ formatting.
|
||||
| CUDA | [nvcc](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) |
|
||||
| C# | [mcs](http://www.mono-project.com/docs/about-mono/languages/csharp/) see:`help ale-cs-mcs` for details, [mcsc](http://www.mono-project.com/docs/about-mono/languages/csharp/) !! see:`help ale-cs-mcsc` for details and configuration|
|
||||
| Chef | [foodcritic](http://www.foodcritic.io/) |
|
||||
| Clojure | [joker](https://github.com/candid82/joker) |
|
||||
| CMake | [cmakelint](https://github.com/richq/cmake-lint) |
|
||||
| CoffeeScript | [coffee](http://coffeescript.org/), [coffeelint](https://www.npmjs.com/package/coffeelint) |
|
||||
| Crystal | [crystal](https://crystal-lang.org/) !! |
|
||||
|
32
ale_linters/clojure/joker.vim
Normal file
32
ale_linters/clojure/joker.vim
Normal file
@ -0,0 +1,32 @@
|
||||
" Author: Nic West <nicwest@mailbox.org>
|
||||
" Description: linter for clojure using joker https://github.com/candid82/joker
|
||||
|
||||
function! ale_linters#clojure#joker#HandleJokerFormat(buffer, lines) abort
|
||||
" output format
|
||||
" <filename>:<line>:<column>: <issue type>: <message>
|
||||
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Read error|Parse error|Parse warning|Exception): ?(.+))$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:type = 'E'
|
||||
if l:match[4] is? 'Parse warning'
|
||||
let l:type = 'W'
|
||||
endif
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('clojure', {
|
||||
\ 'name': 'joker',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'joker',
|
||||
\ 'command': 'joker --lint %t',
|
||||
\ 'callback': 'ale_linters#clojure#joker#HandleJokerFormat',
|
||||
\})
|
21
doc/ale-clojure.txt
Normal file
21
doc/ale-clojure.txt
Normal file
@ -0,0 +1,21 @@
|
||||
===============================================================================
|
||||
ALE Clojure Integration *ale-clojure-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
joker *ale-clojure-joker*
|
||||
|
||||
Joker is a small Clojure interpreter and linter written in Go.
|
||||
|
||||
https://github.com/candid82/joker
|
||||
|
||||
Linting options are not configurable by ale, but instead are controlled by a
|
||||
`.joker` file in same directory as the file (or current working directory if
|
||||
linting stdin), a parent directory relative to the file, or the users home
|
||||
directory.
|
||||
|
||||
see https://github.com/candid82/joker#linter-mode for more information.
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
@ -29,6 +29,8 @@ CONTENTS *ale-contents*
|
||||
gcc.................................|ale-c-gcc|
|
||||
chef..................................|ale-chef-options|
|
||||
foodcritic..........................|ale-chef-foodcritic|
|
||||
clojure...............................|ale-clojure-options|
|
||||
joker...............................|ale-clojure-joker|
|
||||
cmake.................................|ale-cmake-options|
|
||||
cmakelint...........................|ale-cmake-cmakelint|
|
||||
cpp...................................|ale-cpp-options|
|
||||
@ -271,6 +273,7 @@ Notes:
|
||||
* CUDA: `nvcc`!!
|
||||
* C#: `mcs`, `mcsc`!!
|
||||
* Chef: `foodcritic`
|
||||
* Clojure: `joker`
|
||||
* CMake: `cmakelint`
|
||||
* CoffeeScript: `coffee`, `coffeelint`
|
||||
* Crystal: `crystal`!!
|
||||
|
75
test/handler/test_clojure_joker_handler.vader
Normal file
75
test/handler/test_clojure_joker_handler.vader
Normal file
@ -0,0 +1,75 @@
|
||||
Before:
|
||||
runtime ale_linters/clojure/joker.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(the clojure joker handler should be able to handle errors):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 123,
|
||||
\ 'col': 44,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'Read error: Unexpected )',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#clojure#joker#HandleJokerFormat(0, [
|
||||
\ 'test.clj:123:44: Read error: Unexpected )',
|
||||
\ ])
|
||||
|
||||
Execute(the clojure joker handler should be able to handle warnings):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 654,
|
||||
\ 'col': 321,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'Parse warning: let form with empty body',
|
||||
\ }
|
||||
\ ],
|
||||
\ ale_linters#clojure#joker#HandleJokerFormat(0, [
|
||||
\ 'test.clj:654:321: Parse warning: let form with empty body'
|
||||
\ ])
|
||||
|
||||
Execute(the clojure joker handler should be able to handle exceptions):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 123,
|
||||
\ 'col': 321,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'Exception: something horrible happen',
|
||||
\ }
|
||||
\ ],
|
||||
\ ale_linters#clojure#joker#HandleJokerFormat(0, [
|
||||
\ 'test.clj:123:321: Exception: something horrible happen'
|
||||
\ ])
|
||||
|
||||
Execute(the clojure joker handler should be able to handle errors from stdin):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 16,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'Read error: Unexpected )',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#clojure#joker#HandleJokerFormat(0, [
|
||||
\ '<stdin>:16:1: Read error: Unexpected )',
|
||||
\ ])
|
||||
|
||||
Execute(the clojure joker handler should be able to handle windows files):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 123,
|
||||
\ 'col': 44,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'Read error: Unexpected )',
|
||||
\ }
|
||||
\ ],
|
||||
\ ale_linters#clojure#joker#HandleJokerFormat(0, [
|
||||
\ 'C:\my\operating\system\is\silly\core.clj:123:44: Read error: Unexpected )',
|
||||
\ ])
|
Loading…
Reference in New Issue
Block a user