mirror of https://github.com/dense-analysis/ale
Robot framework rflint support (#3715)
* Create rflint.vim support for robot framework by creating ale definition for rflint syntax linter * robot framework - rflint support
This commit is contained in:
parent
bf29f6ea92
commit
19437e25d0
|
@ -0,0 +1,46 @@
|
|||
" Author: Samuel Branisa <branisa.samuel@icloud.com>
|
||||
" Description: rflint linting for robot framework files
|
||||
|
||||
call ale#Set('robot_rflint_executable', 'rflint')
|
||||
|
||||
function! ale_linters#robot#rflint#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'robot_rflint_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#robot#rflint#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#robot#rflint#GetExecutable(a:buffer)
|
||||
let l:flags = '--format'
|
||||
\ . ' "{filename}:{severity}:{linenumber}:{char}:{rulename}:{message}"'
|
||||
|
||||
return l:executable
|
||||
\ . ' '
|
||||
\ . l:flags
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#robot#rflint#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^([[:alnum:][:punct:]]+):(W|E):([[:digit:]]+):([[:digit:]]+):([[:alnum:]]+):(.*)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'filename': l:match[1],
|
||||
\ 'type': l:match[2],
|
||||
\ 'lnum': str2nr(l:match[3]),
|
||||
\ 'col': str2nr(l:match[4]),
|
||||
\ 'text': l:match[5],
|
||||
\ 'detail': l:match[6],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('robot', {
|
||||
\ 'name': 'rflint',
|
||||
\ 'executable': function('ale_linters#robot#rflint#GetExecutable'),
|
||||
\ 'command': function('ale_linters#robot#rflint#GetCommand'),
|
||||
\ 'callback': 'ale_linters#robot#rflint#Handle',
|
||||
\})
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
===============================================================================
|
||||
ALE Robot Integration *ale-robot-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
rflint *ale-robot-rflint*
|
||||
|
||||
g:ale_robot_rflint_executable *g:ale_robot_rflint_executable*
|
||||
*b:ale_robot_rflint_executable*
|
||||
Type: |String|
|
||||
Default: `'rflint'`
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
|
@ -454,6 +454,8 @@ Notes:
|
|||
* `textlint`
|
||||
* `vale`
|
||||
* `write-good`
|
||||
* Robot
|
||||
* `rflint`
|
||||
* RPM spec
|
||||
* `rpmlint`
|
||||
* Ruby
|
||||
|
|
|
@ -2979,6 +2979,8 @@ documented in additional help files.
|
|||
restructuredtext........................|ale-restructuredtext-options|
|
||||
textlint..............................|ale-restructuredtext-textlint|
|
||||
write-good............................|ale-restructuredtext-write-good|
|
||||
robot...................................|ale-robot-options|
|
||||
rflint................................|ale-robot-rflint|
|
||||
ruby....................................|ale-ruby-options|
|
||||
brakeman..............................|ale-ruby-brakeman|
|
||||
debride...............................|ale-ruby-debride|
|
||||
|
|
|
@ -463,6 +463,8 @@ formatting.
|
|||
* [textlint](https://textlint.github.io/)
|
||||
* [vale](https://github.com/ValeLint/vale)
|
||||
* [write-good](https://github.com/btford/write-good)
|
||||
* Robot
|
||||
* [rflint](https://github.com/boakley/robotframework-lint)
|
||||
* RPM spec
|
||||
* [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`)
|
||||
* Ruby
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
Before:
|
||||
runtime ale_linters/robot/rflint.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(Warning and error messages should be handled correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 1,
|
||||
\ 'filename': 'test.robot',
|
||||
\ 'type': 'W',
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 2,
|
||||
\ 'text': 'RequireSuiteDocumentation',
|
||||
\ 'detail': 'No suite documentation',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 1,
|
||||
\ 'filename': 'test.robot',
|
||||
\ 'type': 'E',
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 4,
|
||||
\ 'text': 'RequireTestDocumentation',
|
||||
\ 'detail': 'No testcase documentation',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#robot#rflint#Handle(1, [
|
||||
\ 'test.robot:W:1:2:RequireSuiteDocumentation:No suite documentation',
|
||||
\ 'test.robot:E:3:4:RequireTestDocumentation:No testcase documentation'
|
||||
\])
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('robot', 'rflint')
|
||||
let b:rflint_format = ' --format'
|
||||
\ . ' "{filename}:{severity}:{linenumber}:{char}:{rulename}:{message}" %s'
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
unlet! b:rflint_format
|
||||
|
||||
Execute(The rflint command callback should return default string):
|
||||
AssertLinter 'rflint',
|
||||
\ 'rflint'
|
||||
\ . b:rflint_format
|
||||
|
||||
Execute(The rflint executable should be configurable):
|
||||
let g:ale_robot_rflint_executable = '~/.local/bin/rflint'
|
||||
|
||||
AssertLinter '~/.local/bin/rflint',
|
||||
\ '~/.local/bin/rflint'
|
||||
\ . b:rflint_format
|
Loading…
Reference in New Issue