golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.65k stars 1.39k forks source link

golangci-lint producing different output in different machines #3141

Closed gane5hvarma closed 2 years ago

gane5hvarma commented 2 years ago

Welcome

Description of the problem

I have installed the latest version of golangci-lint(1.49.0). When its run on my local machine its throwing lint errors which is are correct. But when run on github actions its not showing any lint issues, which makes me less confident to use it in ci pipeline

Version of golangci-lint

```console $ golangci-lint --version golangci-lint has version 1.49.0 built from cc2d97f3 on 2022-08-24T10:24:37Z ```

Configuration file

```console $ cat .golangci.yml # paste output here run: # Define the Go version limit. # Mainly related to generics support in go1.18. # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17 go: '1.18' linters: # all these linters will execute when golangci-lint is run enable: - deadcode - errcheck - gosimple - govet - ineffassign - staticcheck - structcheck - varcheck - bodyclose - decorder - makezero - nilnil - nilerr - rowserrcheck - tenv - wastedassign - unparam - misspell - unconvert - gofumpt - gofmt disable: - unused - typecheck ```

Go environment

```console $ go version && go env go version go1.18.3 darwin/arm64 ```

Verbose output of running

```console $ golangci-lint cache clean $ golangci-lint run -v Running [/home/runner/golangci-lint-1.49.0-linux-amd64/golangci-lint run --out-format=github-actions -v --timeout 10m --out-${NO_FUTURE}format colored-line-number] in [] ... level=info msg="[config_reader] Config search paths: [./ /home/runner/work/repo/repo /home/runner/work/repo /home/runner/work /home/runner /home /]" level=info msg="[config_reader] Used config file .golangci.yaml" level=info msg="[lintersdb] Active 21 linters: [bodyclose deadcode decorder errcheck gofmt gofumpt gosimple govet ineffassign makezero misspell nilerr nilnil rowserrcheck staticcheck structcheck tenv unconvert unparam varcheck wastedassign]" level=info msg="[loader] Go packages loading at mode 575 (compiled_files|deps|types_sizes|exports_file|files|imports|name) took [19](https://github.com/magic/repo/runs/8029178048?check_suite_focus=true#step:4:21).048863742s" level=warning msg="[runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused." level=warning msg="[runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused." level=warning msg="[runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused." level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 9.424021ms" level=info msg="[linters context/goanalysis] analyzers took 10.118741702s with top 10 stages: buildir: 8.44851643s, inspect: 681.692392ms, ctrlflow: 232.04498ms, printf: 176.281938ms, fact_deprecated: 138.868458ms, fact_purity: 113.457485ms, nilness: 111.260882ms, SA5012: 110.008876ms, typedness: 71.19947ms, unconvert: 8.612422ms" level=warning msg="[linters context] rowserrcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649." level=warning msg="[linters context] structcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649." level=warning msg="[linters context] wastedassign is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649." level=info msg="[runner] Issues before processing: 1976, after processing: 0" level=info msg="[runner] Processors filtering stat (out/in): filename_unadjuster: 1976/1976, exclude-rules: 1976/1976, cgo: 1976/1976, path_prettifier: 1976/1976, autogenerated_exclude: 1976/1976, skip_dirs: 1976/1976, identifier_marker: 1976/1976, skip_files: 1976/1976, exclude: 1976/1976, nolint: 0/1976" level=info msg="[runner] processing took 113.785194ms with stages: exclude-rules: 74.805993ms, identifier_marker: 33.728487ms, nolint: 3.65071ms, path_prettifier: 981.503µs, skip_dirs: 299.701µs, cgo: 123µs, filename_unadjuster: 98µs, autogenerated_exclude: 92.1µs, max_same_issues: 1.8µs, uniq_by_line: 700ns, path_prefixer: 600ns, skip_files: 500ns, max_from_linter: 400ns, exclude: 400ns, diff: 300ns, source_code: 300ns, max_per_file_from_linter: [20](https://github.com/magic/repo/runs/8029178048?check_suite_focus=true#step:4:22)0ns, severity-rules: 200ns, sort_results: 200ns, path_shortener: 100ns" level=info msg="[runner] linters took 8.[22](https://github.com/magic/repo/runs/8029178048?check_suite_focus=true#step:4:24)6404601s with stages: goanalysis_metalinter: 8.112465807s, rowserrcheck: 13.4µs, structcheck: 7.1µs, wastedassign: 7.1µs" level=info msg="File cache stats: 1 entries of total size 303B" level=info msg="Memory: 274 samples, avg is 132.8MB, max is 456.4MB" level=info msg="Execution took 27.29[23](https://github.com/magic/repo/runs/8029178048?check_suite_focus=true#step:4:25)2[25](https://github.com/magic/repo/runs/8029178048?check_suite_focus=true#step:4:27)75s" golangci-lint found no issues Ran golangci-lint in [27](https://github.com/magic/repo/runs/8029178048?check_suite_focus=true#step:4:29)[40](https://github.com/magic/repo/runs/8029178048?check_suite_focus=true#step:4:42)4ms ```

Code example or link to a public repository

```go Working on a private repository. Will try to reproduce on a public code ```
boring-cyborg[bot] commented 2 years ago

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

ldez commented 2 years ago

Hello,

can you provide the different outputs?

gane5hvarma commented 2 years ago

@ldez The above output is from github actions. The below output is from my local machine

INFO [config_reader] Config search paths: [./ /Users/ganesh/magic/repo /Users/ganesh/magic /Users/ganesh/Users /] 
INFO [config_reader] Used config file .golangci.yaml 
INFO [lintersdb] Active 21 linters: [bodyclose deadcode decorder errcheck gofmt gofumpt gosimple govet ineffassign makezero misspell nilerr nilnil rowserrcheck staticcheck structcheck tenv unconvert unparam varcheck wastedassign] 
INFO [loader] Go packages loading at mode 575 (types_sizes|exports_file|name|imports|compiled_files|deps|files) took 533.497833ms 
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused. 
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused. 
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused. 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 3.165333ms 
INFO [linters context/goanalysis] analyzers took 15.681801583s with top 10 stages: buildir: 9.344975736s, buildssa: 818.130918ms, inspect: 744.726114ms, printf: 625.833346ms, fact_deprecated: 601.981614ms, ctrlflow: 485.527087ms, nilness: 473.911909ms, fact_purity: 448.142124ms, typedness: 350.026128ms, SA5012: 347.505069ms 
WARN [linters context] rowserrcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649. 
WARN [linters context] structcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649. 
WARN [linters context] wastedassign is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649. 
INFO [runner/max_same_issues] 4/7 issues with text "File is not `gofumpt`-ed" were hidden, use --max-same-issues 
INFO [runner] Issues before processing: 65, after processing: 16 
INFO [runner] Processors filtering stat (out/in): diff: 20/20, max_same_issues: 16/20, path_prefixer: 16/16, path_prettifier: 65/65, skip_dirs: 65/65, identifier_marker: 65/65, nolint: 26/50, uniq_by_line: 20/26, max_from_linter: 16/16, source_code: 16/16, sort_results: 16/16, exclude-rules: 50/65, max_per_file_from_linter: 20/20, path_shortener: 16/16, severity-rules: 16/16, filename_unadjuster: 65/65, skip_files: 65/65, autogenerated_exclude: 65/65, exclude: 65/65, cgo: 65/65 
INFO [runner] processing took 8.221581ms with stages: nolint: 5.397417ms, identifier_marker: 764.208µs, exclude-rules: 736.958µs, autogenerated_exclude: 561.667µs, path_prettifier: 399.459µs, source_code: 183.917µs, skip_dirs: 123.875µs, max_same_issues: 17.583µs, cgo: 15.166µs, uniq_by_line: 5.75µs, max_from_linter: 4.999µs, filename_unadjuster: 3.834µs, max_per_file_from_linter: 2.625µs, path_shortener: 2.291µs, exclude: 792ns, severity-rules: 291ns, diff: 291ns, skip_files: 208ns, sort_results: 125ns, path_prefixer: 125ns 
INFO [runner] linters took 3.474966667s with stages: goanalysis_metalinter: 3.466573917s, rowserrcheck: 10.125µs, structcheck: 5.666µs, wastedassign: 4.125µs 
tests/file_test.go:18:6: `testProfile` is unused (deadcode)
func testSomething(t *testing.T) {
     ^
core/utils/somefile.go:167:16: Error return value of `worktree.Pull` is not checked (errcheck)
                worktree.Pull(&git.PullOptions{
                             ^
tests/somefile_test.go:115:9: Error return value of `cmd.Run` is not checked (errcheck)
        cmd.Run()
               ^
core/utils/pretty.go:19: File is not `gofmt`-ed with `-s` (gofmt)

core/utils/pretty.go:22: File is not `gofumpt`-ed (gofumpt)
        csvData, err := os.OpenFile(csvPath, os.O_CREATE|os.O_WRONLY, 0644)
core/registry/types.go:193: File is not `gofumpt`-ed (gofumpt)
}

INFO File cache stats: 78 entries of total size 303.5KiB 
INFO Memory: 42 samples, avg is 681.0MB, max is 961.4MB 
INFO Execution took 4.046977542s

I'm happy to get on a call and show you the issue live as well

ldez commented 2 years ago

I'm happy to get on a call and show you the issue live as well

This will never happen, I'm not free personal support.


deadcode is deprecated and the other problems are related to a change from go1.19.

WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.

bombsimon commented 2 years ago

Go 1.19 issue and gofmt relates to #3110, #3109, #3101, #3069, #3098, #3109, #3063.

xfwangustc commented 1 year ago

I'd got the same problem like yours, have you got the solution?