mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
Improve luacheck setup [skip appveyor]
- Move .luacheckrc to root, add read_globals=vim - Simplify lualint target, run it on all lua files - Lint preload.lua, but ignore W211 - Remove testlint target, included in lualint (and lint) - Clean up .luacheckrc
This commit is contained in:
parent
571b2c5e7b
commit
32361a1245
19
.luacheckrc
Normal file
19
.luacheckrc
Normal file
@ -0,0 +1,19 @@
|
||||
-- vim: ft=lua tw=80
|
||||
|
||||
-- Ignore W211 (unused variable) with preload files.
|
||||
files["**/preload.lua"] = {ignore = { "211" }}
|
||||
|
||||
-- Don't report unused self arguments of methods.
|
||||
self = false
|
||||
|
||||
-- Rerun tests only if their modification time changed.
|
||||
cache = true
|
||||
|
||||
ignore = {
|
||||
"631", -- max_line_length
|
||||
}
|
||||
|
||||
-- Global objects defined by the C code
|
||||
read_globals = {
|
||||
"vim",
|
||||
}
|
@ -666,37 +666,12 @@ if(BUSTED_LUA_PRG)
|
||||
endif()
|
||||
|
||||
if(LUACHECK_PRG)
|
||||
add_custom_target(testlint
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DLUACHECK_PRG=${LUACHECK_PRG}
|
||||
-DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
|
||||
-DIGNORE_PATTERN="*/preload.lua"
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake)
|
||||
|
||||
add_custom_target(
|
||||
lintbuiltinlua
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DLUACHECK_PRG=${LUACHECK_PRG}
|
||||
-DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src/nvim/lua
|
||||
-DREAD_GLOBALS=vim
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake
|
||||
)
|
||||
add_custom_target(
|
||||
lintruntimelua
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DLUACHECK_PRG=${LUACHECK_PRG}
|
||||
-DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/runtime/lua
|
||||
-DREAD_GLOBALS=vim
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake
|
||||
)
|
||||
# TODO(ZyX-I): Run linter for all lua code in src
|
||||
add_custom_target(
|
||||
lualint
|
||||
DEPENDS lintruntimelua
|
||||
DEPENDS lintbuiltinlua
|
||||
)
|
||||
add_custom_target(lualint
|
||||
COMMAND ${LUACHECK_PRG} -q runtime/ src/ test/
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
else()
|
||||
add_custom_target(lualint false
|
||||
COMMENT "lualint: LUACHECK_PRG not defined")
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_NAME "Neovim")
|
||||
|
7
Makefile
7
Makefile
@ -135,9 +135,6 @@ functionaltest: | nvim
|
||||
functionaltest-lua: | nvim
|
||||
+$(BUILD_CMD) -C build functionaltest-lua
|
||||
|
||||
testlint: | build/.ran-cmake deps
|
||||
$(BUILD_CMD) -C build testlint
|
||||
|
||||
lualint: | build/.ran-cmake deps
|
||||
$(BUILD_CMD) -C build lualint
|
||||
|
||||
@ -182,6 +179,6 @@ appimage:
|
||||
appimage-%:
|
||||
bash scripts/genappimage.sh $*
|
||||
|
||||
lint: check-single-includes clint testlint lualint
|
||||
lint: check-single-includes clint lualint
|
||||
|
||||
.PHONY: test testlint lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix
|
||||
.PHONY: test lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix
|
||||
|
@ -14,12 +14,6 @@ run_test 'make clint-full' clint
|
||||
|
||||
exit_suite --continue
|
||||
|
||||
enter_suite 'testlint'
|
||||
|
||||
run_test 'make testlint' testlint
|
||||
|
||||
exit_suite --continue
|
||||
|
||||
enter_suite 'lualint'
|
||||
|
||||
run_test 'make lualint' lualint
|
||||
|
@ -1,22 +0,0 @@
|
||||
set(LUACHECK_ARGS -q "${LUAFILES_DIR}")
|
||||
if(DEFINED IGNORE_PATTERN)
|
||||
list(APPEND LUACHECK_ARGS --exclude-files "${LUAFILES_DIR}/${IGNORE_PATTERN}")
|
||||
endif()
|
||||
if(DEFINED CHECK_PATTERN)
|
||||
list(APPEND LUACHECK_ARGS --include-files "${LUAFILES_DIR}/${CHECK_PATTERN}")
|
||||
endif()
|
||||
if(DEFINED READ_GLOBALS)
|
||||
list(APPEND LUACHECK_ARGS --read-globals "${READ_GLOBALS}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${LUACHECK_PRG}" ${LUACHECK_ARGS}
|
||||
WORKING_DIRECTORY "${LUAFILES_DIR}"
|
||||
ERROR_VARIABLE err
|
||||
RESULT_VARIABLE res
|
||||
)
|
||||
|
||||
if(NOT res EQUAL 0)
|
||||
message(STATUS "Output to stderr:\n${err}")
|
||||
message(FATAL_ERROR "Linting tests failed with error: ${res}")
|
||||
endif()
|
@ -75,7 +75,6 @@ for i = 1, #events do
|
||||
end
|
||||
|
||||
if not ev.bridge_impl and not ev.noexport then
|
||||
|
||||
local send, argv, recv, recv_argv, recv_cleanup = '', '', '', '', ''
|
||||
local argc = 1
|
||||
for j = 1, #ev.parameters do
|
||||
@ -161,7 +160,6 @@ for i = 1, #events do
|
||||
call_output:write(";\n")
|
||||
call_output:write("}\n\n")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
proto_output:close()
|
||||
|
@ -40,7 +40,7 @@ local imacros=function(s)
|
||||
return '(intptr_t)' .. s
|
||||
end
|
||||
end
|
||||
local N_=function(s) -- luacheck: ignore 211
|
||||
local N_=function(s) -- luacheck: ignore 211 (currently unused)
|
||||
return function()
|
||||
return 'N_(' .. cstr(s) .. ')'
|
||||
end
|
||||
|
@ -1,20 +0,0 @@
|
||||
-- vim: ft=lua tw=80
|
||||
|
||||
-- Don't report globals from luajit or busted (e.g. jit.os or describe).
|
||||
std = '+luajit +busted'
|
||||
|
||||
-- One can't test these files properly; assume correctness.
|
||||
exclude_files = { '*/preload.lua' }
|
||||
|
||||
-- Don't report unused self arguments of methods.
|
||||
self = false
|
||||
|
||||
-- Rerun tests only if their modification time changed.
|
||||
cache = true
|
||||
|
||||
ignore = {
|
||||
"631", -- max_line_length
|
||||
}
|
||||
|
||||
-- Ignore whitespace issues in converted Vim legacy tests.
|
||||
--files["functional/legacy"] = {ignore = { "611", "612", "613", "621" }}
|
@ -208,8 +208,6 @@ Guidelines
|
||||
[contained in an `it()` block](https://github.com/neovim/neovim/blob/d21690a66e7eb5ebef18046c7a79ef898966d786/test/functional/ex_cmds/grep_spec.lua#L11).
|
||||
Provide empty function argument if the `pending()` call is outside of `it()`
|
||||
([example](https://github.com/neovim/neovim/commit/5c1dc0fbe7388528875aff9d7b5055ad718014de#diff-bf80b24c724b0004e8418102f68b0679R18)).
|
||||
- Use `make testlint` for using the shipped luacheck program ([supported by syntastic](https://github.com/scrooloose/syntastic/blob/d6b96c079be137c83009827b543a83aa113cc011/doc/syntastic-checkers.txt#L3546))
|
||||
to lint all tests.
|
||||
- Really long `source([=[...]=])` blocks may break syntax highlighting. Try
|
||||
`:syntax sync fromstart` to fix it.
|
||||
|
||||
@ -235,7 +233,7 @@ by the semantic component they are testing.
|
||||
Lint
|
||||
====
|
||||
|
||||
`make lint` (and `make testlint`) runs [luacheck](https://github.com/mpeterv/luacheck)
|
||||
`make lint` (and `make lualint`) runs [luacheck](https://github.com/mpeterv/luacheck)
|
||||
on the test code.
|
||||
|
||||
If a luacheck warning must be ignored, specify the warning code. Example:
|
||||
|
Loading…
Reference in New Issue
Block a user