diff options
author | Daniel Hahler <git@thequod.de> | 2019-07-04 05:30:16 +0200 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-07-04 12:29:54 +0200 |
commit | 32361a1245d1584ae074702aa645bc20e353f787 (patch) | |
tree | 66043fdb5d8e280f85de2552bbb72cc700e612f0 | |
parent | 571b2c5e7be105d23ada987a7c7080f8631bfd15 (diff) | |
download | rneovim-32361a1245d1584ae074702aa645bc20e353f787.tar.gz rneovim-32361a1245d1584ae074702aa645bc20e353f787.tar.bz2 rneovim-32361a1245d1584ae074702aa645bc20e353f787.zip |
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
-rw-r--r-- | .luacheckrc | 19 | ||||
-rw-r--r-- | CMakeLists.txt | 37 | ||||
-rw-r--r-- | Makefile | 7 | ||||
-rwxr-xr-x | ci/run_lint.sh | 6 | ||||
-rw-r--r-- | cmake/RunLuacheck.cmake | 22 | ||||
-rw-r--r-- | src/nvim/generators/gen_api_ui_events.lua | 2 | ||||
-rw-r--r-- | src/nvim/options.lua | 2 | ||||
-rw-r--r-- | test/.luacheckrc | 20 | ||||
-rw-r--r-- | test/README.md | 4 |
9 files changed, 29 insertions, 90 deletions
diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000000..f350ff014a --- /dev/null +++ b/.luacheckrc @@ -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", +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 832e37436f..e9d997ef3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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 diff --git a/ci/run_lint.sh b/ci/run_lint.sh index ae9adb7c87..54e76e10da 100755 --- a/ci/run_lint.sh +++ b/ci/run_lint.sh @@ -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 diff --git a/cmake/RunLuacheck.cmake b/cmake/RunLuacheck.cmake deleted file mode 100644 index 4887e562a5..0000000000 --- a/cmake/RunLuacheck.cmake +++ /dev/null @@ -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() diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index e9f30b84f0..3cb117d8b5 100644 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -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() diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 30409807aa..27f72f6441 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -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 diff --git a/test/.luacheckrc b/test/.luacheckrc deleted file mode 100644 index abfa881754..0000000000 --- a/test/.luacheckrc +++ /dev/null @@ -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" }} diff --git a/test/README.md b/test/README.md index c87f835f79..903e93e495 100644 --- a/test/README.md +++ b/test/README.md @@ -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: |