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

Successful exit code (0) when typecheck error #529

Closed
dm3ch opened this issue May 5, 2019 · 5 comments
Closed

Successful exit code (0) when typecheck error #529

dm3ch opened this issue May 5, 2019 · 5 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@dm3ch
Copy link

dm3ch commented May 5, 2019

Thank you for creating the issue!

Please include the following information:

  1. Version of golangci-lint: golangci-lint --version (or git commit if you don't use binary distribution): golangci-lint has version 1.16.0 built from 97ea1cb on 2019-03-31T19:48:46Z
  2. Config file: cat .golangci.yml empty
  3. Go environment: go version && go env
go version go1.12.1 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dmitry.chepurovskiy/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/dmitry.chepurovskiy/Workspace/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/dmitry.chepurovskiy/.gvm/gos/go1.12.1"
GOTMPDIR=""
GOTOOLDIR="/Users/dmitry.chepurovskiy/.gvm/gos/go1.12.1/pkg/tool/darwin_amd64"
GCCGO="gccgo"
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/n3/zjx8n1bd5y12gf4krlbxbp3cmgy7n2/T/go-build361798505=/tmp/go-build -gno-record-gcc-switches -fno-common"
  1. Verbose output of running: golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/dmitry.chepurovskiy/Workspace/go/src/github.com/my-organisation/my-app /Users/dmitry.chepurovskiy/Workspace/go/src/github.com/my-organisation /Users/dmitry.chepurovskiy/Workspace/go/src/github.com /Users/dmitry.chepurovskiy/Workspace/go/src /Users/dmitry.chepurovskiy/Workspace/go /Users/dmitry.chepurovskiy/Workspace /Users/dmitry.chepurovskiy /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck
INFO [loader] Go packages loading at mode load deps types and syntax took 3.037160839s
INFO [loader] SSA repr building timing: packages building 13.88881ms, total 246.626443ms
INFO [loader/astcache] Parsed AST of all pkg.GoFiles: [] for 769ns
INFO [loader] Packages that do not compile: [github.com/my-organisation/my-app/dateranges.test]
WARN [runner/megacheck] Can't run megacheck because of compilation errors in packages [github.com/my-organisation/my-app/dateranges.test]: -:
dateranges/dateranges_test.go:40:18: missing ',' before newline in composite literal
ERRO [runner/typecheck] typechecking error:
dateranges/dateranges_test.go:40:18: missing ',' before newline in composite literal
INFO [runner] worker.3 took 6.962671ms with stages: typecheck: 5.206083ms, structcheck: 1.746699ms
INFO [runner] worker.4 took 159.532297ms with stages: deadcode: 154.615722ms, varcheck: 3.093858ms, errcheck: 1.80885ms
INFO [runner] worker.1 took 377.021335ms with stages: ineffassign: 375.597979ms, megacheck: 1.391022ms
WARN [runner/govet] govet error: assign: analysis skipped due to errors in package
WARN [runner/govet] govet error: atomicalign: analysis skipped due to errors in package
WARN [runner/govet] govet error: bools: analysis skipped due to errors in package
WARN [runner/govet] govet error: buildtag: analysis skipped due to errors in package
WARN [runner/govet] govet error: httpresponse: analysis skipped due to errors in package
WARN [runner/govet] govet error: loopclosure: analysis skipped due to errors in package
WARN [runner/govet] govet error: ctrlflow: analysis skipped due to errors in package
WARN [runner/govet] govet error: lostcancel: failed prerequisites: ctrlflow@github.com/my-organisation/my-app/dateranges.test
WARN [runner/govet] govet error: nilfunc: analysis skipped due to errors in package
WARN [runner/govet] govet error: printf: analysis skipped due to errors in package
WARN [runner/govet] govet error: shift: analysis skipped due to errors in package
WARN [runner/govet] govet error: stdmethods: analysis skipped due to errors in package
WARN [runner/govet] govet error: tests: analysis skipped due to errors in package
WARN [runner/govet] govet error: unmarshal: analysis skipped due to errors in package
WARN [runner/govet] govet error: unsafeptr: analysis skipped due to errors in package
WARN [runner/govet] govet error: unusedresult: analysis skipped due to errors in package
WARN [runner/govet] govet error: buildssa: analysis skipped due to errors in package
WARN [runner/govet] govet error: nilness: failed prerequisites: buildssa@github.com/my-organisation/my-app/dateranges.test
INFO [runner] worker.2 took 376.97477ms with stages: govet: 376.963671ms
INFO [runner] Workers idle times: #1: 682.64µs, #3: 363.272579ms, #4: 128.312551ms
WARN [runner] Can't run linter govet: asmdecl: analysis skipped due to errors in package
INFO [runner] processing took 6.804µs with stages: max_same_issues: 3.28µs, skip_dirs: 548ns, max_from_linter: 520ns, nolint: 416ns, path_prettifier: 306ns, cgo: 207ns, path_shortener: 171ns, exclude: 168ns, autogenerated_exclude: 158ns, diff: 155ns, exclude-rules: 154ns, identifier_marker: 153ns, source_code: 150ns, replacement_builder: 149ns, skip_files: 118ns, max_per_file_from_linter: 83ns, uniq_by_line: 68ns
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 37 samples, avg is 228.2MB, max is 872.7MB
INFO Execution took 3.926624789s

There's an error while linting but golangci-lint exit code is still 0.
Error:

ERRO [runner/typecheck] typechecking error:
dateranges/dateranges_test.go:40:18: missing ',' before newline in composite literal

If i right understood it works so cause of https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/typecheck.go#L49
Such errors are printed but not included into the results' list.

Snippet from the checked code that triggers this error:

	tests := []struct {
		name    string
		args    args
		want    *timestamp.Timestamp
		want1   *timestamp.Timestamp
		wantErr bool
	}{
		{
			name: "Some Name",
			args: args{
				y: "2018",
			},
			want:    start,
			want1:   end,
			wantErr: false
		},
	}

So my question does it expected behavior of linter that error doesn't cause failed exit code?
And is there any options to get this error triggers error code?

@jirfag
Copy link
Member

jirfag commented Jun 10, 2019

thank you for reporting! I can't reproduce it on this example but I fixed it in #567

@jirfag
Copy link
Member

jirfag commented Jun 10, 2019

please, check it

@dm3ch
Copy link
Author

dm3ch commented Jun 12, 2019

@jirfag Thank you, now I'm getting exit code 7 on that case

@alejandrodnm
Copy link

AIf I use v1.16.0 golangci-lint run fails with the compilation errors, but v1.17.X finishes successfully.

This is an issue for me when using vim-go because I first get the compilation errors, but then golangci is executed and returns a zero code which is a success and it clears the window with all the errors.

v1.17.0

λ ➜ golangci-lint run --print-issued-lines=false --build-tags --disable-all --exclude-use-default=false --enable=govet --enable=golint /XXX/internal/pkg/datapoints -v
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 6 linters: [errcheck goconst goimports golint govet unused]
INFO [loader] Go packages loading at mode load types and syntax took 2.20355365s
INFO [loader] SSA repr building timing: packages building 13.318747ms, total 142.705893ms
INFO [loader] Packages that do not compile: [XXX/internal/pkg/datapoints [XXX/internal/pkg/datapoints.test]]
INFO [runner] worker.1 took 163.543µs with stages: govet: 70.887µs, errcheck: 28.992µs, golint: 25.177µs, unused: 11.673µs, goconst: 5.082µs, goimports: 4.216µs
INFO [runner] worker.6 took 2.265µs
INFO [runner] worker.3 took 18.42µs
INFO [runner] worker.5 took 2.162µs
INFO [runner] worker.2 took 1.024µs
INFO [runner] worker.7 took 1.889µs
INFO [runner] worker.4 took 1.422µs
INFO [runner] worker.8 took 1.007µs
INFO [runner] Workers idle times: #1: 345.767µs, #2: 56.33µs, #3: 154.668µs, #4: 31.988µs, #5: 85.086µs, #6: 241.18µs, #7: 42.047µs
INFO [runner] processing took 24.326µs with stages: max_same_issues: 20.099µs, nolint: 510ns, cgo: 474ns, skip_dirs: 472ns, autogenerated_exclude: 407ns, max_from_linter: 397ns, filename_unadjuster: 287ns, identifier_marker: 239ns, diff: 233ns, path_prettifier: 225ns, path_shortener: 189ns, skip_files: 185ns, source_code: 164ns, max_per_file_from_linter: 149ns, uniq_by_line: 101ns, exclude: 99ns, exclude-rules: 96ns
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 29 samples, avg is 141.0MB, max is 404.5MB
INFO Execution took 2.72559047s

v1.16.0

INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 6 linters: [errcheck goconst goimports golint govet unused]
INFO [loader] Go packages loading at mode load deps types and syntax took 1.407765419s
INFO [loader] SSA repr building timing: packages building 22.413231ms, total 196.637741ms
INFO [loader] Packages that do not compile: [XXX/internal/pkg/datapoints [XXX/internal/pkg/datapoints.test]]
WARN [runner/unused] Can't run megacheck because of compilation errors in packages [XXX/internal/pkg/datapoints [XXX/internal/pkg/datapoints.test]]: internal/pkg/datapoints/datapoints.go:75: expected 1 expression and 11 more errors: run `golangci-lint run --no-config --disable-all -E typecheck` to see all errors
INFO [runner] worker.8 took 130.624µs with stages: unused: 127.004µs
INFO [runner] worker.3 took 2.483µs
INFO [runner] worker.6 took 1.122µs
INFO [runner] worker.5 took 58.056µs with stages: errcheck: 54.679µs
INFO [runner] worker.7 took 188.726µs with stages: goconst: 184.112µs
INFO [runner] worker.1 took 443.866µs with stages: goimports: 435.762µs
WARN [runner] Can't run linter goimports: /XXX/internal/pkg/datapoints/datapoints.go:75:5: expected 1 expression (and 3 more errors)
INFO [runner] worker.4 took 81.143481ms with stages: golint: 81.124597ms
internal/pkg/datapoints/datapoints.go:17:6: exported type `Attributes` should have comment or be unexported (golint)
internal/pkg/datapoints/datapoints.go:19:6: exported type `Metric` should have comment or be unexported (golint)
internal/pkg/datapoints/datapoints.go:28:6: exported type `Observation` should have comment or be unexported (golint)
internal/pkg/datapoints/datapoints.go:33:1: exported function `NewObservation` should have comment or be unexported (golint)
internal/pkg/datapoints/datapoints.go:39:6: exported type `DatapointsApi` should have comment or be unexported (golint)
internal/pkg/datapoints/datapoints.go:45:1: exported function `NewDatapointsApi` should have comment or be unexported (golint)
internal/pkg/datapoints/datapoints.go:56:1: exported function `NewDatapointsApiWithRoundTripper` should have comment or be unexported (golint)
internal/pkg/datapoints/datapoints.go:62:1: exported method `DatapointsApi.Post` should have comment or be unexported (golint)
internal/pkg/datapoints/delta.go:19:6: exported type `DeltaCalculator` should have comment or be unexported (golint)
internal/pkg/datapoints/delta.go:24:1: exported function `NewDeltaCalculator` should have comment or be unexported (golint)
internal/pkg/datapoints/delta.go:30:1: comment on exported method `DeltaCalculator.CalculateDelta` should be of the form `CalculateDelta ...` (golint)
internal/pkg/datapoints/delta.go:46:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (golint)
internal/pkg/datapoints/delta.go:52:1: comment on exported method `DeltaCalculator.RemoveStale` should be of the form `RemoveStale ...` (golint)
WARN [runner/govet] govet error: assign: analysis skipped due to errors in package
WARN [runner/govet] govet error: atomicalign: analysis skipped due to errors in package
WARN [runner/govet] govet error: bools: analysis skipped due to errors in package
WARN [runner/govet] govet error: buildtag: analysis skipped due to errors in package
WARN [runner/govet] govet error: httpresponse: analysis skipped due to errors in package
WARN [runner/govet] govet error: loopclosure: analysis skipped due to errors in package
WARN [runner/govet] govet error: ctrlflow: analysis skipped due to errors in package
WARN [runner/govet] govet error: lostcancel: failed prerequisites: ctrlflow@XXX/internal/pkg/datapoints [XXX/internal/pkg/datapoints.test]
WARN [runner/govet] govet error: nilfunc: analysis skipped due to errors in package
WARN [runner/govet] govet error: printf: analysis skipped due to errors in package
WARN [runner/govet] govet error: shift: analysis skipped due to errors in package
WARN [runner/govet] govet error: stdmethods: analysis skipped due to errors in package
WARN [runner/govet] govet error: tests: analysis skipped due to errors in package
WARN [runner/govet] govet error: unmarshal: analysis skipped due to errors in package
WARN [runner/govet] govet error: unsafeptr: analysis skipped due to errors in package
WARN [runner/govet] govet error: unusedresult: analysis skipped due to errors in package
WARN [runner/govet] govet error: buildssa: analysis skipped due to errors in package
WARN [runner/govet] govet error: nilness: failed prerequisites: buildssa@XXX/internal/pkg/datapoints [XXX/internal/pkg/datapoints.test]
INFO [runner] worker.2 took 88.598848ms with stages: govet: 88.587403ms
INFO [runner] Workers idle times: #1: 88.135094ms, #3: 88.42841ms, #4: 7.454271ms, #5: 88.411302ms, #6: 88.418595ms, #7: 88.374282ms, #8: 88.439151ms
WARN [runner] Can't run linter govet: asmdecl: analysis skipped due to errors in package
INFO [runner] Issues before processing: 17, after processing: 13
INFO [runner] processing took 1.288358ms with stages: identifier_marker: 617.885µs, cgo: 171.126µs, source_code: 143.796µs, skip_dirs: 142.644µs, nolint: 78.37µs, autogenerated_exclude: 55.184µs, path_prettifier: 31.781µs, max_same_issues: 19.412µs, path_shortener: 7.734µs, uniq_by_line: 6.272µs, max_from_linter: 5.186µs, replacement_builder: 3.738µs, max_per_file_from_linter: 3.099µs, skip_files: 668ns, diff: 577ns, exclude: 492ns, exclude-rules: 394ns
INFO File cache stats: 2 entries of total size 4.5KiB
INFO Memory: 22 samples, avg is 182.0MB, max is 470.6MB
INFO Execution took 2.030076378s

@jirfag jirfag reopened this Sep 11, 2019
@tpounds
Copy link
Contributor

tpounds commented Oct 5, 2019

Closing this as a duplicate of #276 to track adding support for failing with non-zero exit code on compilation errors.

@tpounds tpounds added the duplicate This issue or pull request already exists label Oct 5, 2019
@tpounds tpounds closed this as completed Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants