Skip to content
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

Broken code is not reported as broken by the linter #2533

Closed
dcu opened this issue Oct 3, 2019 · 9 comments
Closed

Broken code is not reported as broken by the linter #2533

dcu opened this issue Oct 3, 2019 · 9 comments

Comments

@dcu
Copy link

dcu commented Oct 3, 2019

What did you do? (required: The issue will be closed when not provided)

  1. enable golint-ci with auto checking when saving the file
  2. Create a broken program like
package main

import "fmt"

func main() {
	broken
}
  1. Save it

What did you expect to happen?

Get the possible lines where the code is broken, it used to be like that with gometalinter

What happened instead?

No errors were reported

Configuration (MUST fill this out):

let g:go_metalinter_command = "golangci-lint"
let g:go_metalinter_enabled = ['govet', 'golint', 'errcheck', 'gocyclo', 'deadcode', 'gosimple', 'staticcheck']
let g:go_metalinter_autosave_enabled = ['govet', 'golint', 'errcheck', 'gocyclo', 'deadcode', 'gosimple', 'staticcheck']
let g:go_metalinter_autosave = 1
let g:go_metalinter_deadline = "60s"

vim-go version:

master

vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):

vimrc

Vim version (first three lines from :version):

8.1

Go version (go version):

1.13

Go environment

go env Output:
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="..."
GOENV="..."
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/tmp/"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/x1/2rp2t8l903d7dfdh9ldcpcs00000gn/T/go-build390465344=/tmp/go-build -gno-record-gcc-switches -fno-common"
@dcu
Copy link
Author

dcu commented Oct 3, 2019

I tracked down this issue to golangci/golangci-lint#276

@bhcleek
Copy link
Collaborator

bhcleek commented Oct 3, 2019

You can workaround this by including typecheck in your enabled linters.

@bhcleek bhcleek closed this as completed Oct 3, 2019
@dcu
Copy link
Author

dcu commented Oct 3, 2019

is it documented somewhere? It was really frustrating

@dcu
Copy link
Author

dcu commented Oct 3, 2019

I just tried it, enabling typecheck didn't work

@bhcleek
Copy link
Collaborator

bhcleek commented Oct 3, 2019

we discovered that while looking into a similar issue: #2475 (comment)

@dcu
Copy link
Author

dcu commented Oct 3, 2019

looks like that workaround is no longer working @bhcleek in the terminal it's still 0 exit code (successful)

@bhcleek bhcleek reopened this Oct 3, 2019
@dcu
Copy link
Author

dcu commented Oct 3, 2019

the commit from golangci-lint that breaks the workaround is 95ec0cf21ea4720ec9555c43176ab8b1d1b035f2 I just bisected it

@bhcleek
Copy link
Collaborator

bhcleek commented Oct 3, 2019

Thanks for the heads up.

There's not much that vim-go can do about this; ultimately, it's a bug in golangci-lint.

@g00nix
Copy link

g00nix commented Dec 11, 2019

add this to your .vimrc:

nnoremap <F6> :w <CR> :GoTestCompile <CR> <CR>

When you want to save and check errors, hit F6. It will have the behavior you expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants