Skip to content

fix: wrong load mode #1733

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

Merged
merged 4 commits into from
Feb 14, 2021
Merged

fix: wrong load mode #1733

merged 4 commits into from
Feb 14, 2021

Conversation

ldez
Copy link
Member

@ldez ldez commented Feb 14, 2021

Fixes #1515

I tested all the linters.

To avoid that in the future, every testdata for a linter must contain at least one import.

Before the fix:

$ go run ./cmd/golangci-lint/ run --no-config --disable-all --enable=asciicheck ./test/testdata/depguard.go 
WARN [runner] Can't run linter asciicheck: asciicheck: analysis skipped: errors in package: [/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:6:2: could not import compress/gzip (Config.Importer.Import(compress/gzip) returned nil but no error) /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:7:2: could not import log (Config.Importer.Import(log) returned nil but no error)] 
ERRO Running error: asciicheck: analysis skipped: errors in package: [/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:6:2: could not import compress/gzip (Config.Importer.Import(compress/gzip) returned nil but no error) /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:7:2: could not import log (Config.Importer.Import(log) returned nil but no error)] 
exit status 3
$ go run ./cmd/golangci-lint/ run --no-config --disable-all --enable=exhaustivestruct ./test/testdata/depguard.go
WARN [runner] Can't run linter exhaustivestruct: inspect: analysis skipped: errors in package: [/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:6:2: could not import compress/gzip (Config.Importer.Import(compress/gzip) returned nil but no error) /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:7:2: could not import log (Config.Importer.Import(log) returned nil but no error)] 
ERRO Running error: inspect: analysis skipped: errors in package: [/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:6:2: could not import compress/gzip (Config.Importer.Import(compress/gzip) returned nil but no error) /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:7:2: could not import log (Config.Importer.Import(log) returned nil but no error)] 
exit status 3
$ go run ./cmd/golangci-lint/ run --no-config --disable-all --enable=exportloopref ./test/testdata/depguard.go
WARN [runner] Can't run linter exportloopref: inspect: analysis skipped: errors in package: [/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:6:2: could not import compress/gzip (Config.Importer.Import(compress/gzip) returned nil but no error) /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:7:2: could not import log (Config.Importer.Import(log) returned nil but no error)] 
ERRO Running error: inspect: analysis skipped: errors in package: [/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:6:2: could not import compress/gzip (Config.Importer.Import(compress/gzip) returned nil but no error) /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:7:2: could not import log (Config.Importer.Import(log) returned nil but no error)] 
exit status 3
$ go run ./cmd/golangci-lint/ run --no-config --disable-all --enable=makezero ./test/testdata/depguard.go
WARN [runner] Can't run linter makezero: makezero: analysis skipped: errors in package: [/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:6:2: could not import compress/gzip (Config.Importer.Import(compress/gzip) returned nil but no error) /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:7:2: could not import log (Config.Importer.Import(log) returned nil but no error)] 
ERRO Running error: makezero: analysis skipped: errors in package: [/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:6:2: could not import compress/gzip (Config.Importer.Import(compress/gzip) returned nil but no error) /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata/depguard.go:7:2: could not import log (Config.Importer.Import(log) returned nil but no error)] 
exit status 3

@ldez ldez added the bug Something isn't working label Feb 14, 2021
@ldez ldez mentioned this pull request Feb 14, 2021
3 tasks
@cbandy
Copy link
Contributor

cbandy commented Feb 14, 2021

Did adding the import statements cause existing tests to fail?

@ldez
Copy link
Member Author

ldez commented Feb 14, 2021

Without my fix, those tests fail with an import.

Copy link
Contributor

@cbandy cbandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@SVilgelm
Copy link
Member

It's weird, but it works, I just tested on master and with this changes.

Copy link
Member

@SVilgelm SVilgelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you

@SVilgelm SVilgelm merged commit 1b30a17 into golangci:master Feb 14, 2021
@ldez ldez deleted the fix/load-mode branch February 14, 2021 18:29
@ldez ldez mentioned this pull request Feb 17, 2021
ashanbrown pushed a commit to ashanbrown/golangci-lint that referenced this pull request Feb 20, 2021
* fix: asciicheck

* fix: exportloopref

* fix: exhaustivestruct

* fix: makezero
@ldez ldez mentioned this pull request Apr 3, 2021
4 tasks
@ldez ldez added this to the v1.37 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't run linter exportloopref
3 participants