What caught my eye was the 'luacheck' linting tool: https://github.com/mpeterv/luacheck
Here I already tried out the tool manually which can create a report of your code issues... but then the section on integration with editors caught my other eye. So I tried sublime... hated it, and couldn't get the linter to work either.
Then I tried Brackets which is available on all systems it seems: http://brackets.io/
From here I installed it, ran it and went to File -> 'Extension Manager'. Then I searched for 'luacheck' and installed the interface for it.
I also had to download luacheck from the github page, actually I got the one-off windows x86_64 binary and put it somewhere on my system. This needs to be reachable in the PATH, so I linked it in the system settings:
https://github.com/mpeterv/luacheck/rel ... acheck.exe
Now when I opened my working directory in Brackets I can see the source tree on the left, I open a file and it auto-lints the file. Neat.
To configure luacheck properly, I create '.luacheckrc' which is written in basic Lua syntax and normally placed into the root directory of your code. However, to get this to work properly with Brackets I created a symbolic link (or just copy it) to:
"%LOCALAPPDATA%\Luacheck\.luacheckrc"
On other systems I beleive this file should be copied to:
"~/Library/Application Support/Luacheck/.luacheckrc" on OS X/macOS, and "$XDG_CONFIG_HOME/luacheck/.luacheckrc" or "~/.config/luacheck/.luacheckrc" on a linux type OS.
My '.luacheckrc' consists of the following settings, to give you an idea of how to set it up:
Code: Select all
-- Create symbolic link of this file into this directory: %LOCALAPPDATA%\Luacheck\.luacheckrc
-- Include 'love' into the global pool (read/write)
std = {
globals = {"love"}
}
-- Include all source sub-dirs or file paths relative to the root dir:
include_files = {
"./game/",
"./monkey_box/",
"main.lua"
}
-- Message codes to filter out:
-- https://luacheck.readthedocs.io/en/stable/warnings.html
-- 611 A line consists of nothing but white space
-- 612 A line contains trailing white space
-- 614 Trailing white space in a comment
-- 631 line is too long
-- 311 value assigned to variable x is unused
-- 113 accessing undefined variable x
-- 111 setting non-standard global variable x
-- 411 variable x was previously defined on line
-- 542 empty if branch
-- 422 shadowing definition of argument
-- 421 shadowing definition of variable
ignore = {"611", "612", "614", "631", "311", "113", "111", "411", "542", "422", "421"}
So I spent about a day of coding time to tidy up my code and really really enjoyed using this linter, I think I cleaned up over 2000 warnings and found three bugs in the process, heh.
I realised that some features are lacking in Brackets such as a more sensible search/replace tool, but I think there are a lot of plugins being made or available.
So have you tried this, what do you think?