Skip to content

Using diagnostics.severity setting in .luarc.json seems to break the severity level filtering in generated report #2730

@tomlau10

Description

@tomlau10

How are you using the lua-language-server?

Command Line

Which OS are you using?

MacOS

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

I am trying to integrate LuaLS checking into CI so I am testing around with lua-language-server command line. In our codebase there are some functions marked with @deprecated, its default severity is 2 (Warning). We don't want it to be reported so I added the following setting into the .luarc.json:

    "diagnostics.severity": {
        "deprecated": "Information!"
    },

I expected that when running the following command, the report will not contains deprecated (as the severity is downgraded):

${path_to_luals}/bin/lua-language-server --check=.

Actual Behaviour

Out of my expectation, the generated report includes all those redefined-local messages which are of severity level 4 (Hint). 😳 I have tried adding flag --checklevel=Warning but got same result.

With a bit of testing, if I tried to add diagnostics.severity setting (even if an empty table "diagnostics.severity": {}, ), then the generated report will ignore the --checklevel value.
Only if I remove the diagnostics.severity setting, the generated report becomes normal again (only reports Warning or above)

Reproduction steps

  1. prepare a workspace with the following files
  • a.lua
local a
  • .luarc.json
{
    "diagnostics.severity": {},
}
  1. run command line ${path_to_luals}/bin/lua-language-server --check=.
  2. it will output Diagnosis complete, 1 problems found, see ... check.json, and the file content of check.json
{
    "file:///Users/tomlau10/projects/temp/./a.lua": [
        {
            "code": "unused-local",
            "message": "Unused local `a`.",
            "range": {
                "end": {
                    "character": 7,
                    "line": 0
                },
                "start": {
                    "character": 6,
                    "line": 0
                }
            },
            "severity": 4,
            "source": "Lua Diagnostics.",
            "tags": [
                1
            ]
        }
    ]
}
  1. when removing "diagnostics.severity": {}, in .luarc.json, the diagnosis will not found any problem.

Additional Notes

Strange enough, with --checklevel=Error flag then the diagnosis will show no problems found 🤔.

But with either --checklevel=Warning and --checklevel=Information, the report will include these unused-local, which should be at hint level and should not be included.

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions