summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Branisa <branisa.samuel@windowslive.com>2021-09-11 02:19:17 +0200
committerGitHub <noreply@github.com>2021-09-11 09:19:17 +0900
commit19437e25d05950ab83dce285b4b8ec5166e06dba (patch)
treef961d8ddc232dbd0123021b770f3aebe39b472e2
parentbf29f6ea92ff993d5d96bc4e760f315e95e332a5 (diff)
downloadale-19437e25d05950ab83dce285b4b8ec5166e06dba.zip
Robot framework rflint support (#3715)
* Create rflint.vim support for robot framework by creating ale definition for rflint syntax linter * robot framework - rflint support
-rw-r--r--ale_linters/robot/rflint.vim46
-rw-r--r--doc/ale-robot.txt16
-rw-r--r--doc/ale-supported-languages-and-tools.txt2
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md2
-rw-r--r--test/handler/test_rflint_handler.vader33
-rw-r--r--test/linter/test_rflint.vader20
7 files changed, 121 insertions, 0 deletions
diff --git a/ale_linters/robot/rflint.vim b/ale_linters/robot/rflint.vim
new file mode 100644
index 00000000..8fe2d797
--- /dev/null
+++ b/ale_linters/robot/rflint.vim
@@ -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',
+\})
+
diff --git a/doc/ale-robot.txt b/doc/ale-robot.txt
new file mode 100644
index 00000000..405ae277
--- /dev/null
+++ b/doc/ale-robot.txt
@@ -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:
+
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index ba2d2255..32e38b89 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -454,6 +454,8 @@ Notes:
* `textlint`
* `vale`
* `write-good`
+* Robot
+ * `rflint`
* RPM spec
* `rpmlint`
* Ruby
diff --git a/doc/ale.txt b/doc/ale.txt
index ddcc9d3f..9a21e9f0 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -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|
diff --git a/supported-tools.md b/supported-tools.md
index 4de9328c..4e04b53a 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -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
diff --git a/test/handler/test_rflint_handler.vader b/test/handler/test_rflint_handler.vader
new file mode 100644
index 00000000..f2670141
--- /dev/null
+++ b/test/handler/test_rflint_handler.vader
@@ -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'
+ \])
+
diff --git a/test/linter/test_rflint.vader b/test/linter/test_rflint.vader
new file mode 100644
index 00000000..0ee97b30
--- /dev/null
+++ b/test/linter/test_rflint.vader
@@ -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