[Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Mon Jan 11 20:52:48 MSK 2021


Hi! Thanks for the patch!

See 2 comments below.

> diff --git a/.luacheckrc b/.luacheckrc
> index 4b829f3dc..17cff8671 100644
> --- a/.luacheckrc
> +++ b/.luacheckrc
> @@ -102,3 +108,53 @@ files["src/box/lua/console.lua"] = {
>          "212",
>      }
>  }
> +files["test/box/box.lua"] = {
> +    globals = {
> +        "cfg_filter",
> +        "sorted",
> +        "iproto_request",
> +    }
> +}
> +files["test/box/lua/push.lua"] = {
> +    globals = {"push_collection"}
> +}
> +files["test/box/lua/index_random_test.lua"] = {
> +    globals = {"index_random_test"}
> +}
> +files["test/box/lua/utils.lua"] = {
> +    globals = {
> +        "arithmetic",
> +        "check_space",
> +        "create_iterator",
> +        "iterate",
> +        "setmap",
> +        "sort",
> +        "space_field_types",
> +        "space_bsize",
> +        "table_generate",
> +        "table_shuffle",
> +        "tuple_to_string",

1. All these functions are returned by the module. It means,
they are supposed to be used like this:

	utils = require('utils.lua')
	utils.setmap()
	utils.space_bsize()
	-- etc

This in turn means you need to make them all 'local' in utils.lua.
I did it, and the tests pass. Also some of these functions are
probably unused, but I didn't check.

The same for identifier.lua below.

> +    }
> +}
> +files["test/box/lua/bitset.lua"] = {
> +    globals = {
> +        "clear",
> +        "create_space",
> +        "delete",
> +        "drop_space",
> +        "dump",
> +        "fill",
> +        "test_insert_delete",

2. Almost the same here. With a difference that the functions
are not returned now. But they are used in a single file, so their
'return' like in utils.lua does should be easy to do.

The same for fifo.lua below.

> +    }
> +}
> +files["test/box/lua/fifo.lua"] = {
> +    globals = {
> +        "fifomax",
> +        "fifo_push",
> +        "fifo_top",
> +        "find_or_create_fifo",
> +    }
> +}
> +files["test/box/lua/identifier.lua"] = {
> +     globals = {"run_test"}
> +}


More information about the Tarantool-patches mailing list