iamcco / diagnostic-languageserver

diagnostic language server integrate with linters
MIT License
418 stars 28 forks source link

Source Name is used wrong #90

Open FalcoGer opened 1 year ago

FalcoGer commented 1 year ago

Describe the bug When the file is set to the sourceName, coc will display the file path as the diagnostic source, which is useless.

Furthermore, when sourceNameFilter is set, this prevents the display of diagnostics because it filters the diagnostic source with the file name. A separate filename/filepath entry should be used instead for such a filter.

The source is the source of the diagnostic, not the file that is diagnosed, as such the source for example should be "shellcheck ${level}" and not the the json path to the "file" field.

But this can't be used because sourceName checks the json object's path for the provided string instead of interpreting it like message does, causing the parsing to fail.

Curiously "spellcheck" is the source, set correctly, when sourceName is not provided.

To Reproduce Steps to reproduce the behavior

  1. Use this config for shellcheck
    "diagnostic-languageserver.linters": {
        "shellcheck": {
            "sourceName": "shellcheck",
            "command": "shellcheck",
            "args": [ "--format=json", "--enable=all", "--severity=style", "--shell=bash", "%file"],
            "parseJson": {
                "errorsRoot": "",
                "sourceName": "shellcheck ${level}",
                "sourceNameFilter": true,
                "line": "line",
                "endLine": "endLine",
                "column": "column",
                "endColumn": "endColumn",
                "security": "level",
                "message": "${message} [${code}]"
            },
            "securities": {
                "error": "error",
                "warning": "warning",
                "note": "info",
                "style": "hint"
            }
        }
    },
  2. Open this file
    
    #!/bin/bash

echo ls -al

3. No diagnostics

**Expected behavior**

A sourceNameFilter should be renamed to fileNameFilter, and an additional element should be added to the parsers to get the file name if a filter is to be used on that.
I would then like to do something like

```json
[...]
"file": "file",
"fileNameFilter": true,
"security": "level",                  // should be severity, by the way
"sourceName": "shellcheck ${level}"
[...]

Screenshots image

Desktop (please complete the following information):

Log: diagnostics-languageserver.log