-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linting package loses line information for lint issues #743
Comments
@A-UNDERSCORE-D Thanks for the report - what lint tool are you using? I couldn't reproduce this issue with the default |
golangci-lint. Sorry apparently I missed it in the config, my settings.json isnt organized well. relevant snippets: "go.lintFlags": [
"--fast"
],
"go.lintTool": "golangci-lint", and a part I missed: "go.editorContextMenuCommands": {
"fillStruct": true,
"toggleTestFile": true,
"addTags": true,
"removeTags": false,
"testAtCursor": true,
"testFile": false,
"testPackage": false,
"generateTestForFunction": true,
"generateTestForFile": false,
"generateTestForPackage": false,
"addImport": true,
"testCoverage": true,
"playground": true,
"debugTestAtCursor": true,
}, For the linter itself, here is its config file, just in case Ive missed something in their code. I checked the debug output before I posted and it looked the same for both, so Im assuming its something your side linters-settings:
govet:
check-shadowing: true
gocognit:
min-complexity: 15
maligned:
suggest-new: true
misspell:
locale: GB
gocritic: # cSpell: disable-line
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
linters:
disable-all: true
# cSpell: disable
enable:
- megacheck
- deadcode
- dogsled
- dupl
- errcheck
- gocognit
- goconst
- gocritic
- gocyclo
- gosec
- govet
- golint
- gofmt
- ineffassign
- lll
- maligned
- nakedret
- scopelint
- structcheck
- typecheck
- unconvert
- unparam
- varcheck
- whitespace
- wsl
- misspell
- funlen
- bodyclose
- goprintffuncname
- interfacer
- nakedret
- godox
- goerr113
- nestif
- nolintlint
- gofumpt
run:
max-issues-per-linter: 0
skip-dirs:
- internal/transport/network
skip-dirs-use-default: true
issues:
exclude-use-default: false
exclude:
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
# Unmarshal XML and JSON are obvious in what they do. Lets not.
- exported method `.+\.Unmarshal(?:XML|JSON)` should have comment or be unexported
# golint: Annoying issue about not having a comment. The rare codebase has such comments
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
# golint: False positive when tests are defined in package 'test'
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
# govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
# - ineffective break statement. Did you mean to break out of the outer loop
# gosec: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# gosec: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# gosec: Duplicated errcheck checks
- G104
# gosec: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
# gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable |
Change https://golang.org/cl/259797 mentions this issue: |
@A-UNDERSCORE-D thanks for the complete reproducible example. As described in the cl/259797 commit message, this problem is primarily caused by the fact that the underlying tools do not provide the complete error range info and the extension had to reconstruct reasonable ranges vscode would like. I couldn't find a reasonable workaround for complete fix yet but I hope this problem becomes less severe as underlying tools (e.g. gopls) for linting/vetting provide complete range infos and vscode do not need this type of hack. |
Yeah I gave it a read earlier. Thanks for trying :D Hopefully the backends get a bit better about it. Until then I'm sure your fix will suffice. |
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gocode -v
orcode-insiders -v
to get version of VS Code or VS Code Insidersgo env
to get the go development environment detailsShare the Go related settings you have added/edited
Describe the bug
Lint issue location on line (as in from index x to y, for underlining. See image below)
I would expect both issue existence and line location to be kept.
Steps to reproduce the behavior:
Screenshots or recordings
Expected behavior (file was linted with that file's tab open)
Actual behavior when linting another file and this one gets caught up with it:
The text was updated successfully, but these errors were encountered: