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

Unclear error message on a syntax error #886

Closed
3 tasks done
agnivade opened this issue Dec 10, 2019 · 2 comments · Fixed by #1861
Closed
3 tasks done

Unclear error message on a syntax error #886

agnivade opened this issue Dec 10, 2019 · 2 comments · Fixed by #1861
Assignees
Labels
enhancement New feature or improvement

Comments

@agnivade
Copy link
Contributor

Thank you for creating the issue!

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56Z
Config file

https://github.com/mattermost/mattermost-server/blob/master/.golangci.yml

Go environment
$ go version && go env
go version go1.13.3 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/agniva/.cache/go-build"
GOENV="/home/agniva/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="gitlab.com"
GONOSUMDB="gitlab.com"
GOOS="linux"
GOPATH="/home/agniva/play/go"
GOPRIVATE="gitlab.com"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/agniva/play/go/src/github.com/mattermost/mattermost-server/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build167304403=/tmp/go-build -gno-record-gcc-switches"

Whenever I have a syntax error, the error message is packed onto a single line, which makes it hard to diagnose. Just remove any comma or { and run golangci-lint.

Verbose output of running
$golangci-lint run -v ./...
INFO [config_reader] Config search paths: [./ /home/agniva/play/go/src/github.com/mattermost/mattermost-server /home/agniva/play/go/src/github.com/mattermost /home/agniva/play/go/src/github.com /home/agniva/play/go/src /home/agniva/play/go /home/agniva/play /home/agniva /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 10 linters: [deadcode gofmt golint gosimple govet ineffassign structcheck unconvert unused varcheck] 
INFO [loader] Go packages loading at mode 575 (exports_file|imports|deps|files|name|types_sizes|compiled_files) took 1.362576059s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 330.637983ms 
INFO [runner/unused/goanalysis] analyzers took 2.054162ms with top 10 stages: buildssa: 1.313166ms, U1000: 740.996µs 
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/home/agniva/play/go/src/github.com/mattermost/mattermost-server/store/sqlstore/user_store.go:1138:3: expected operand, found 'return'] 
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 31.821416ms with top 10 stages: inspect: 1.464287ms, findcall: 1.392011ms, ctrlflow: 981.429µs, buildssa: 949.182µs, printf: 867.813µs, isgenerated: 534.749µs, asmdecl: 519.249µs, buildtag: 512.311µs, golint: 507.229µs, tests: 502.73µs 
WARN [runner] Can't run linter goanalysis_metalinter: deadcode: analysis skipped: errors in package: [/home/agniva/play/go/src/github.com/mattermost/mattermost-server/wsapi/api.go:7:2: could not import github.com/mattermost/mattermost-server/v5/app (/home/agniva/play/go/src/github.com/mattermost/mattermost-server/app/server_app_adapters.go:16:2: could not import github.com/mattermost/mattermost-server/v5/store/sqlstore (/home/agniva/play/go/src/github.com/mattermost/mattermost-server/store/sqlstore/user_store.go:1138:3: expected operand, found 'return'))] 
INFO [runner] processing took 4.466µs with stages: max_same_issues: 1.287µs, skip_dirs: 386ns, max_from_linter: 352ns, filename_unadjuster: 308ns, nolint: 290ns, cgo: 257ns, path_prettifier: 241ns, exclude: 199ns, diff: 196ns, identifier_marker: 167ns, autogenerated_exclude: 161ns, source_code: 108ns, exclude-rules: 107ns, path_shortener: 107ns, max_per_file_from_linter: 104ns, skip_files: 102ns, uniq_by_line: 94ns 
INFO [runner] linters took 3.488299632s with stages: unused: 2.216548519s, goanalysis_metalinter: 1.271631816s 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 50 samples, avg is 267.1MB, max is 802.8MB 
INFO Execution took 5.224841104s                  

And moreover, there seems to be unrelated errors also sprouting up:

[/home/agniva/play/go/src/github.com/mattermost/mattermost-server/wsapi/api.go:7:2: could not import github.com/mattermost/mattermost-server/v5/app (/home/agniva/play/go/src/github.com/mattermost/mattermost-server/app/server_app_adapters.go:16:2: could not import github.com/mattermost/mattermost-server/v5/store/sqlstore

I think it will be nice if the each error is printed on a newline, therefore one can clearly see what the error is and act on it. For example, something like this:

WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [
/home/agniva/play/go/src/github.com/mattermost/mattermost-server/store/sqlstore/user_store.go:1138:3: expected operand, found 'return'
]

Also related to #866 which should be fixed.

@tpounds tpounds added the enhancement New feature or improvement label Dec 30, 2019
@ernado
Copy link
Member

ernado commented Feb 4, 2020

Can't agree more! Also we should fix the cryptic "failed prerequisites" error which can hide real cause (e.g. running golangci-lint on kubernetes repo without generated files just nearly caused me a heart attack because It looked like regression for bug we've fixed lately).

@stale
Copy link

stale bot commented Feb 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No recent correspondence or work activity label Feb 6, 2021
@stale stale bot closed this as completed Mar 19, 2021
@ldez ldez reopened this Mar 20, 2021
@stale stale bot removed the stale No recent correspondence or work activity label Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants