Open hanzei opened 11 months ago
This isn't the golangci-lint project, so the issue should be reproduced using only staticcheck, or filed to golangci-lint.
To clarify: the unused
analyzer has a number of options to modify its behavior. These options aren't exposed in Staticcheck because they aren't fully working and not supported. golangci-lint chose to make the options available.
The bug is technically valid in that the code crashes with that option set. However, it isn't relevant to us, because we don't intend for it to be set.
Thanks for the responses :+1:
If configuring unused.Options
is not supported, should the field be unexported? That way it's clear that it's unsupported.
Reproducible here: https://git.helsinki.tools/leon.klingele/unusedbug
$ git clone https://git.helsinki.tools/leon.klingele/unusedbug
$ cd unusedbug
$ golangci-lint run -v ./...
level=info msg="[config_reader] Config search paths: [./ [etc]]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]"
level=info msg="[loader] Go packages loading at mode 575 (exports_file|files|compiled_files|deps|imports|name|types_sizes) took 15.117493ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 141.103µs"
level=info msg="[linters_context/goanalysis] analyzers took 8.535794ms with top 10 stages: ctrlflow: 1.363773ms, printf: 1.314935ms, buildir: 1.033822ms, fact_deprecated: 1.004305ms, fact_purity: 496.049µs, SA4014: 490.846µs, SA5012: 306.318µs, nilness: 287.386µs, typedness: 237.783µs, SA1015: 170.414µs"
level=error msg="[runner] Panic: unused: package \"migrations\" (isInitialPkg: true, needAnalyzeSource: true): object \"error\" has no path but also no column information: goroutine 293 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x5e\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:109 +0x27c\npanic({0x1609ce0?, 0xc000ed6300?})\n\truntime/panic.go:914 +0x21f\nhonnef.co/go/tools/unused.(*SerializedGraph).Merge(0xc000ee9680, {0xc000eea000, 0x5, 0xc000749598?})\n\thonnef.co/go/tools@v0.4.6/unused/serialize.go:52 +0xdde\ngithub.com/golangci/golangci-lint/pkg/golinters.getUnusedResults(0xc000ed5520, 0x96bb05?)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/unused.go:110 +0x1f6\ngithub.com/golangci/golangci-lint/pkg/golinters.runUnused(0xc000ed5520, 0xc000836b78?)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/unused.go:56 +0x2a\ngithub.com/golangci/golangci-lint/pkg/golinters.NewUnused.func1(0x1687b40?)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/unused.go:30 +0x2d\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc000fdff10)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:195 +0x9d6\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:113 +0x17\ngithub.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc000fb03c0, {0x17f69db, 0x6}, 0xc00105f748)\n\tgithub.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0x0?)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:112 +0x7a\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc000fdff10)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xa8\ncreated by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze in goroutine 97\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x205\n"
level=warning msg="[runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: unused: package \"migrations\" (isInitialPkg: true, needAnalyzeSource: true): object \"error\" has no path but also no column information"
level=info msg="[runner] processing took 3.488µs with stages: max_same_issues: 557ns, skip_dirs: 408ns, nolint: 277ns, max_per_file_from_linter: 162ns, uniq_by_line: 162ns, cgo: 146ns, max_from_linter: 145ns, severity-rules: 145ns, autogenerated_exclude: 142ns, path_prettifier: 139ns, exclude: 137ns, skip_files: 137ns, filename_unadjuster: 136ns, source_code: 134ns, exclude-rules: 127ns, fixer: 122ns, identifier_marker: 117ns, path_shortener: 79ns, diff: 79ns, sort_results: 75ns, path_prefixer: 62ns"
level=info msg="[runner] linters took 4.866146ms with stages: goanalysis_metalinter: 4.754298ms"
level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: goanalysis_metalinter: unused: package \"migrations\" (isInitialPkg: true, needAnalyzeSource: true): object \"error\" has no path but also no column information\n\n"
level=info msg="Memory: 2 samples, avg is 24.3MB, max is 26.3MB"
level=info msg="Execution took 27.720611ms"
Found this to be a dup of https://github.com/dominikh/go-tools/issues/1385.
Code base: https://github.com/mattermost/mattermost/tree/master/server Version:
Config:
Logs: