Skip to content

Bring EmmyLua annotations - #68

Open
ligurio wants to merge 14 commits into
masterfrom
ligurio/gh-xxxx-emmylua-annotations
Open

Bring EmmyLua annotations#68
ligurio wants to merge 14 commits into
masterfrom
ligurio/gh-xxxx-emmylua-annotations

Conversation

@ligurio

@ligurio ligurio commented Aug 7, 2026

Copy link
Copy Markdown
Member

locker and others added 13 commits August 7, 2026 17:46
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
ligurio force-pushed the ligurio/gh-xxxx-emmylua-annotations branch from 7b7bb6a to c11d82a Compare August 7, 2026 14:56
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
ligurio force-pushed the ligurio/gh-xxxx-emmylua-annotations branch from c11d82a to 35ed1d9 Compare August 7, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants