FG Spreadshirt Swag
Page 1 of 2 12 Last

Thread: luacheckrc

  1. #1

    luacheckrc

    I've been using luacheck to check my code and really like the detection of non-whitelisted globals (among other things) since it makes typos nearly impossible.
    Unfortunately, luacheck doesn't know about the (many) globals that are part of the FG rulesets and API.

    I've also made a GitHub Action which allows you to generate a luacheckrc file from the rulesets and extensions that you work with.
    The README is pretty clearly written, but you can find my personal example here along with its output here.

    For insight into how I personally use this:
    I use VSCodium for development along with the LuaCoderAssist extension. Setting it up is a bit goofy ("config file path" means path to directory, not path to file -- this of course means the file must have the expected name of ".luacheckrc" -- and you also need to disable "define the luacheck cli options automatically"), but it has a bunch of very neat features to help with lua development and encourage use of slim functions. By using my luacheckrc config file in this way, it automatically underlines MANY common mistakes in real-time as you're editing scripts. For people who want to use global functions without being warned or having to create specific exemptions, add "allow_defined_top = true" to the top of the .luacheckrc file. (suggested by MeAndUnique)
    Last edited by bmos; August 13th, 2022 at 18:34.

  2. #2
    I use it! I add any external class names to it that I reference in my code. I'll check out your config and see how it works for me. Thanks.

  3. #3
    Spent most of my day today working on a script to programmatically generate a luacheck file from extracted ruleset folders.
    Still need to figure out a solution for all the global scripts that are accessed in windowclass scripts, but this is a huge improvement.
    Here is the output: https://github.com/bmos/FG-luacheck/...in/.luacheckrc
    Last edited by bmos; March 20th, 2022 at 02:13.

  4. #4
    Thanks for the submissions you've found so far in your analysis. Very interested in seeing how this turns out, as it may be an interesting tool for our internal ruleset developers.

    Regards,
    JPG

  5. #5
    Still haven't gotten started with the windowcontrol object names (since these are like high level scripts in that they have functions accessible under them), but my GitHub action that creates a luacheckrc file based on FG rulesets with base.xml + lua files and extensions with extension.xml + lua files is ready for wider use

    https://github.com/FG-Unofficial-Dev...ate-luacheckrc

    The README probably has everything needed to generate your own luacheckrc file based on the rulesets and extensions you use/work with and serves as a pretty complete demo. You will have to supply your own unzipped copies of the rulesets and extensions, since those are not mine to share publicly.

  6. #6
    Oh wow! Thanks for sharing this bmos! Having come at lua programming from a purely hobby endeavor, I did not know a thing such as luacheck existed. But as someone that uses static code analysis tools in my day job, I greatly appreciate this tip. I'll definitely take a look at this. I had recently wondered what the little "lua check" tag was on the github page for one of your extensions, but with so little free time, I got distracted and completely forgot about it.

    Cheers,
    Brian

  7. #7
    Quote Originally Posted by MostTornBrain View Post
    Oh wow! Thanks for sharing this bmos! Having come at lua programming from a purely hobby endeavor, I did not know a thing such as luacheck existed. But as someone that uses static code analysis tools in my day job, I greatly appreciate this tip. I'll definitely take a look at this. I had recently wondered what the little "lua check" tag was on the github page for one of your extensions, but with so little free time, I got distracted and completely forgot about it.

    Cheers,
    Brian
    You're welcome! Hopefully it helps you make the most of your hobby time
    Let me know if you have any config questions. I use the file for both auto-linting on github of PRs and commits and also use it in Atom (GitHub's cross-platform open source code editor) with the linter-luacheck plugin so that it analyses my code whenever I stop typing.

  8. #8
    action-generate-luacheck v1.1 now scans provided extensions as well and re-formats package names to avoid syntax errors from luacheck.
    It also scans lua files that aren't 'high level scripts', although not yet to the extent I would like (they aren't nested under the windowcontrol name). You can see an example here.

    I have updated the FG-luacheck repo accordingly so a better pregen file is available to use (now 44,953 lines up from 22,680 lines generated with v1.0)
    Last edited by bmos; March 23rd, 2022 at 21:27.

  9. #9
    After working on this some more, I released v1.2 handles those interface scripts very differently. You can see an example here. I have updated the FG-luacheck repo accordingly so a better pregen file is available to use (now 45,642 lines up from 44,953 lines generated with v1.1).

    Furthermore, today I have released v1.2 which simplifies std definition names of extensions by getting the correct author+name from extension.xml and using that rather than the filename. I have again updated the the FG-luacheck repo so a better pregen file is available to use without setting up your own action (still 45,642 lines).

  10. #10
    After working on this some more, I released v1.2 which handles interface scripts very differently (functions are now nested under the parent windowcontrol rather than the script name--since that doesn't actually matter). You can see an example here. I have updated the FG-luacheck repo accordingly so a better pregen file is available to use (now 45,642 lines up from 44,953 lines generated with v1.1)

    Furthermore, today I have released v1.3 which simplifies std definition names of extensions by getting the correct author+name from extension.xml and using that rather than the filename. I have again updated the the FG-luacheck repo so a better pregen file is available to use without setting up your own action (still 45,642 lines).

    The next thing to tackle is detecting globals that are tables and whitelisting all child entries so that adding entries to ruleset tables doesn't result in a warning.
    Last edited by bmos; March 23rd, 2022 at 21:43.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in