Bring EmmyLua annotations - #68
Open
ligurio wants to merge 14 commits into
Open
Conversation
49 tasks
Compatibility with CMake < 3.5 has been removed from CMake.
This patch bumps actions to use ubuntu-24.04 for fixing the following GitHub
warning:
The Ubuntu 20.04 Actions runner image will begin deprecation
on 2025-02-01.
Part of #TNTP-1918
Closes #64
The patch updates luacheckrc to suppress warnings. Follows up the commit 49fa005 ("test: add linting stage").
The patch adds comments for functions with descriptions and argument types in EmmyLua format. Needed for tarantool/tarantool#13020
The patch introduces an initial configuration file .emmyrc for emmylua_check, it is a modern static analuzer for Lua. The configuration file has the same excluded directories as in .luacheckrc and config disables a number of rules. Most of them will be enabled back in the following commits except the following rules: - "unresolved-require" (7 warnings) is disabled because most modules are Tarantool builtins: `json`, `log`, `uuid`; no source code is included in the project. - "need-check-nil" (22 warnings) is disabled because these warnings are not critical and I don't want to add extra checks to the code. - "redefined-local" is disabled because it was disabled for luacheck in the commit 49fa005 ("test: add linting stage").
The patch rule `assign-type-mismatch` in the .emmyrc and fixes three warnings: - @Class checks moved to the module table - no longer sticks to local ffi. - `checks(...)`: vararg typed as `checks.qualifier|number`, level annotated with ---@type number, stack level retrieved via narrowed local first. - @field checks field consistent with type `fun(...: checks.qualifier|number)`.
The patch enables rule `call-non-callable` and fixes warnings produced by this rule: removed class checks/@field from the modul table, now the `require('checks')` type is inferred from setmetatable (callable via variadic `__call`, checks/_VERSION fields are referenced). Field documentation has been moved to the module header.
The patch enables rule `duplicate-require` in the .emmyrc and removes duplicate require for `ffi` module.
The patch enables rule `param-type-mismatch` in the .emmyrc and fixes 20 warnings produced by this rule.
The patch enables rule `undefined-field` in the .emmyrc and fixes errors produced by this rule. The error is in using `table.deepcopy()` in test/test.lua because Tarantool API is unknown to the analyzer. The patch created a definition for `table.deepcopy()` in a file test/types.lua.
The patch enables `unnecessary-if` in the .emmyrc and fixes a warning produced by this rule. The reason of warning is an unknown type of variable `qualifier`. The analyzer infers the `optional` field as literal `false` and doesn't track the assignment `qualifier.optional = true` inside the `gmatch` loop, so `unnecessary-if` considers the condition is always `false`. This is a false positive - at runtime, the condition is reachable (e.g., '?string'). The patch adds the annotation to the local variable `qualifier` - the `optional` field is now typed as boolean, and the analyzer no longer considers the condition to always be false.
ligurio
force-pushed
the
ligurio/gh-xxxx-emmylua-annotations
branch
from
August 7, 2026 14:56
7b7bb6a to
c11d82a
Compare
The patch enables rule `unused` and fixes a warnings produced by this rule by adding an underscore to the prefix of variables that are not used.
ligurio
force-pushed
the
ligurio/gh-xxxx-emmylua-annotations
branch
from
August 7, 2026 14:59
c11d82a to
35ed1d9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Needed for tarantool/tarantool#13020