Description
TL/DR
Warning message generated by nolintlint
linter, brakes vscode-go
problem reporting. this is caused by npm child_process
executor logic. Current workaround to enable no error code
argument supplied to vscode-go golangci-lint
linter argumens (--issues-exit-code=0
) .
What version of Go, VS Code & VS Code Go extension are you using?
- Run
go version
to get version of Gogo version go1.14.5 darwin/amd64
- Run
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders1.47.2
- Check your installed extensions to get the version of the VS Code Go extension
- none +
golang.go
- none +
- Run
go env
to get the go development environment details- doesn't matter.
Share the Go related settings you have added/edited
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"-c", ".golangci.yml" # example https://github.com/butuzov/dots/blob/master/.golangci.yml
]
Describe the bug
This is an integration bug (found while working with golangci-lint
) and prevents getting Problems found by linter.
It occurs if combinations of factors happen, If linter output has:
- Error_Code, StdErr and StdOut: it's (
vscode-go
) fails to report an code problems. - Error_Code and StdOut: everything works.
- StdOut & StdErr, but no Error_Code: everything works.
Steps to reproduce the behavior:
-
Create
example.go
package main func main() {} // there are no such linter "deaccode", it's a typo, but `nolintlint` linter will show warning (perfectly fine). // and this is braks vsc-go //nolint:deacdcode func add(a, b int) int { a += 10 b += 11 return a + b } func nouse() {}
-
Run VSCode against folder with this file with default settings () to get failed examples.
-
Run VSCode against folder with this file with default settings +
--issues-exit-code=0
in order to get working example.
An example of call to golangci-lint
golangci-lint run --disable-all -E=nolintlint -E=deadcode -E=wsl example.go
Suggestions?
- Add
--issues-exit-code=0
to list of arguments passed togolangci-lint
in addition to existing ones (added in steals mode byvscode-go
) - Adjust logic at https://github.com/golang/vscode-go/blob/master/src/util.ts#L726:L729 as per
Root of the problem
- node js
child_process
:
- report an error, if stderr not empty, and return code is
> 0
- doesn't change
err
if stderr has output and return code is0
test node.js script
const { execFile } = require('child_process');
let args = ['run', '--disable-all', '-E=nolintlint', '-E=deadcode', '-E=wsl'];
['issue.go', 'noissue.go'].forEach((file) => {
['1', '0'].forEach((error_code_report) => {
let testArgs = args.slice();
testArgs.push(`--issues-exit-code=${error_code_report}`, file);
execFile('golangci-lint', testArgs, (err, stdout, stderr) => {
console.info('='.repeat(60));
console.debug(testArgs);
console.log('err', err);
console.log('stdOut exists', stdout.length > 0);
console.log('stdErr exists', stderr.length > 0);
});
});
});
run it
node test.js
against next files https://gist.github.com/butuzov/4a682fd28bc89c1bdb6f1cc7996e9cfb