From 1d1b5155e63df93d2dc700989faec1c40d490d90 Mon Sep 17 00:00:00 2001 From: Adriaan Zonnenberg Date: Sat, 30 Sep 2017 16:38:10 +0200 Subject: [PATCH 1/2] Luacheck: Respect warn_about_trailing_whitespace option See http://luacheck.readthedocs.io/en/stable/warnings.html, warnings 611 to 614. --- ale_linters/lua/luacheck.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ale_linters/lua/luacheck.vim b/ale_linters/lua/luacheck.vim index e15b7301..9f9ca4c4 100644 --- a/ale_linters/lua/luacheck.vim +++ b/ale_linters/lua/luacheck.vim @@ -26,6 +26,12 @@ function! ale_linters#lua#luacheck#Handle(buffer, lines) abort let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) + if !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + \ && l:match[3] is# 'W' + \ && index(range(611, 614), str2nr(l:match[4])) >= 0 + continue + endif + call add(l:output, { \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 0, From 221cb0f8cfbb27c9e2ecb58d01e059fdcfab7f34 Mon Sep 17 00:00:00 2001 From: Adriaan Zonnenberg Date: Thu, 12 Oct 2017 22:59:45 +0200 Subject: [PATCH 2/2] Add some extra tests for luacheck whitespace warnings --- test/handler/test_lua_handler.vader | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/handler/test_lua_handler.vader b/test/handler/test_lua_handler.vader index af1c134e..712c7c59 100644 --- a/test/handler/test_lua_handler.vader +++ b/test/handler/test_lua_handler.vader @@ -1,4 +1,8 @@ +Before: + Save g:ale_warn_about_trailing_whitespace + After: + Restore call ale#linter#Reset() Execute(The luacheck handler should parse lines correctly): @@ -30,3 +34,25 @@ Execute(The luacheck handler should parse lines correctly): \ ' /file/path/here.lua:3:5: (W213) unused loop variable ''k''', \ ' /file/path/here.lua:3:19: (W113) accessing undefined variable ''x''', \ ]) + +Execute(The luacheck handler should respect the warn_about_trailing_whitespace option): + runtime ale_linters/lua/luacheck.vim + + let g:ale_warn_about_trailing_whitespace = 0 + + AssertEqual + \ [ + \ { + \ 'lnum': 5, + \ 'col': 43, + \ 'text': 'W212: unused argument ''g''', + \ 'type': 'W', + \ } + \ ], + \ ale_linters#lua#luacheck#Handle(347, [ + \ '/file/path/here.lua:15:97: (W614) trailing whitespace in a comment', + \ '/file/path/here.lua:16:60: (W612) line contains trailing whitespace', + \ '/file/path/here.lua:17:1: (W611) line contains only whitespace', + \ '/file/path/here.lua:27:57: (W613) trailing whitespace in a string', + \ '/file/path/here.lua:5:43: (W212) unused argument ''g''', + \ ])