-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warns on error-prone and unnecessary negations #46
Conversation
ac48341
to
c3f5e79
Compare
One false positive here: sometimes metatables override the various boolean operators, and end up implementing them in terms of each other. |
c3f5e79
to
4443fb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. It looks pretty good to me. I do want to put it through a couple paces before merging, but as far as I'm concerned this is on the right track.
Having not actually run this bot looking at the code, then looking at use cases from my own code, wouldn't this be a false positive for a situation like this: if not (t and #t >= 1 and t[#t].prop) then ... end ? |
Nope, that's still clean. Neither rule has anything to say about the negation of a conjunction. |
I'll update the docs to talk specifically about 'relational operators' rather than 'binary boolean operators'; that's the correct term, and it's clearer that conjunctions aren't included. |
4443fb2
to
35dde99
Compare
Oh, one more false-positive case: if one side is NaN, the proposed replacement would fail. (Because for any concrete number, NaN isn't greater than, equal to, or less than that number.) |
35dde99
to
bc6176c
Compare
@alerque For context- I have a local test suite of 13 large open source projects that use luacheck already; the only false positive, so far as I can tell, was luarocks, line 63 here: https://github.com/luarocks/luarocks/blob/master/src/luarocks/core/vers.lua It seems like no projects actually cared about the NaN case, but in theory that could matter too. I've clarified messaging for both cases. |
bbd4153
to
eb62cc3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my only remaining objection is the false positives this generates in my own projects, but the cases are all metatable related and convoluted that the reason why they use an unconventional order really should be annotated anyway, so having to adding a lint suppression seems fair enough.
@arichard4 It might be a good idea to submit a fix with a lint suppressor for that Luarocks metatable trickery (or flip it and add a |
|
Both the luajit test jobs seems to frequently suffer segfaults. Some things I've noticed: (1) They're both building against Luajit 2.1-beta3, which is way out of date (from 2017); plausibly they should try to build against a more recent commit instead. The build target seems to come from https://github.com/leafo/gh-actions-lua/blob/master/.github/workflows/publish.yml |
Closes #43