iamcco / iamcco/diagnostic-languageserver

Source Name is used wrong

Open
#90 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
439
Forks
30
PR merge metrics
No merged PRs in 30d

Description

**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
```json
"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
```bash
#!/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](https://github.com/iamcco/diagnostic-languageserver/assets/16250196/de4ebbee-3cf3-4424-8742-cc9bff3b0f89)

**Desktop (please complete the following information):**
- OS: Ubuntu Mate 22.04 LTS

Log:
[diagnostics-languageserver.log](https://github.com/iamcco/diagnostic-languageserver/files/13239083/diagnostics-languageserver.log)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the parseJson configuration handling for sourceName and sourceNameFilter, using the supplied shellcheck configuration and Bash example to reproduce the missing diagnostics. Done means the diagnostic source is interpreted separately from the diagnosed file and file-based filtering can be configured without suppressing diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.