golangci / golangci-lint

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

Running v1.56.0 version throws panics, v1.55.2 works fine #4361

Closed maksim-paskal closed 5 months ago

maksim-paskal commented 5 months ago

Welcome

Description of the problem

Running today latest version

go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.0 run -v

throws panics

ERRO Running error: can't run linter goanalysis_metalinter
goanalysis_metalinter: interfacer: package "main" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference 
#.golangci.yml
run:
  timeout: 5m
issues:
  fix: true
linters:
  enable-all: true
  disable:
  - gochecknoglobals
  - exhaustivestruct
  - exhaustruct
  - varnamelen
  - musttag
  - depguard

Version of golangci-lint

```console > go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.0 --version golangci-lint has version v1.56.0 built with go1.21.5 from (unknown, mod sum: "h1:uivqYQ8WbkWAE4LgjLLhxsTyb68FlcZF3ZIF0oyn4WQ=") on (unknown) ```

Configuration

```yaml run: timeout: 5m issues: fix: true linters: enable-all: true disable: - gochecknoglobals - exhaustivestruct - exhaustruct - varnamelen - musttag - depguard ```

Go environment

```console go version go1.21.5 darwin/amd64 ```

Verbose output of running

```console WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: interfacer: package "client" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference INFO [runner] processing took 3.335µs with stages: max_same_issues: 502ns, uniq_by_line: 411ns, skip_dirs: 334ns, nolint: 287ns, cgo: 203ns, source_code: 133ns, autogenerated_exclude: 130ns, filename_unadjuster: 127ns, fixer: 125ns, identifier_marker: 125ns, skip_files: 125ns, exclude: 125ns, path_prettifier: 120ns, exclude-rules: 119ns, max_from_linter: 111ns, diff: 67ns, path_shortener: 60ns, sort_results: 60ns, severity-rules: 59ns, max_per_file_from_linter: 58ns, path_prefixer: 54ns INFO [runner] linters took 16.579660199s with stages: goanalysis_metalinter: 16.579591126s ERRO Running error: can't run linter goanalysis_metalinter goanalysis_metalinter: interfacer: package "client" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference INFO Memory: 168 samples, avg is 1038.6MB, max is 1648.4MB INFO Execution took 17.114056017s ```

A minimal reproducible example or link to a public repository

https://github.com/maksim-paskal/aks-node-termination-handler

Validation

boring-cyborg[bot] commented 5 months ago

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

ldez commented 5 months ago

Hello @maksim-paskal,

interfacer is deprecated.

Can you add this to your configuration?

linters:
  enable-all: true
  disable:
    - deadcode # deprecated
    - exhaustivestruct # deprecated
    - golint # deprecated
    - ifshort # deprecated
    - interfacer # deprecated
    - maligned # deprecated
    - nosnakecase # deprecated
    - scopelint # deprecated
    - structcheck # deprecated
    - varcheck # deprecated
    - gochecknoglobals
    - exhaustivestruct
    - exhaustruct
    - varnamelen
    - musttag
    - depguard
maksim-paskal commented 5 months ago

@ldez thanks for quick answer, yes it helps

Do I need to add all deprecated linters now in my configuration?

ldez commented 5 months ago

I tried your repository and my suggestion fix your problem.

Interfacer is a very very old linter, deprecated for years.

Do I need to add all deprecated linters now in my configuration?

yes

maksim-paskal commented 5 months ago

@ldez how about disable-deprecated: true?

#.golangci.yml
run:
  timeout: 5m
issues:
  fix: true
linters:
  enable-all: true
  disable-deprecated: true
  disable:
  - gochecknoglobals
  - exhaustivestruct
  - exhaustruct
  - varnamelen
  - musttag
  - depguard

I try to use all new linters by default. I did not pay attention to deprecated linters, perhaps other users do the same.

ldez commented 5 months ago

The lifecycle deprecated linters is something discussed in #1987.

FYI the deprecation are displayed when you run golangci-lint:

$ golangci-lint run
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 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. 
WARN [runner] The linter 'interfacer' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.  
WARN [runner] The linter 'nosnakecase' is deprecated (since v1.48.1) due to: The repository of the linter has been deprecated by the owner. Replaced by revive(var-naming). 
WARN [runner] The linter 'maligned' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner. Replaced by govet 'fieldalignment'. 
WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive. 
WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner. Replaced by exportloopref. 
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 'ifshort' is deprecated (since v1.48.0) due to: The repository of the linter has been deprecated by the owner.