Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Config migration omits nakedret config when max-func-lines is set to 0 #5754

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

Closed
6 of 7 tasks
chris-reeves opened this issue Apr 21, 2025 · 1 comment · Fixed by #5755
Closed
6 of 7 tasks

Config migration omits nakedret config when max-func-lines is set to 0 #5754

chris-reeves opened this issue Apr 21, 2025 · 1 comment · Fixed by #5755
Assignees
Labels
area: migration bug Something isn't working

Comments

@chris-reeves
Copy link
Contributor

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

How did you install golangci-lint?

Other

Description of the problem

The following config fails to be migrated from v1 to v2 using the migrate command:

linters-settings:
  nakedret:
    max-func-lines: 0

as the nakedret config is missing from the migrated config.

For example:

linters-settings:
  nakedret:
    max-func-lines: 0
  other-linter:
    other-linter-setting: "foo"

becomes:

version: "2"
linters:
  settings:
    other-linter:
      other-linter-setting: "foo"

I've confirmed that the tests will fail if testdata/yaml/linters-settings_nakedret[.golden].yml are changed to specify 0 as the value for max-func-lines.

I tried tweaking the NakedretSettings struct in pkg/commands/internal/migrate/versiontwo/linters_settings.go to see whether this would resolve the issue (I realise this is an autogenerated file) but it does not. Basically, the resulting struct is indistinguishable from the zero value. This is a bit of an edge-case as this is the only config setting for this linter and 0 is a valid, non-default, value.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 2.1.2 built with go1.24.2 from 00a561d on 2025-04-15T13:16:26Z

Configuration

linters-settings:
  nakedret:
    max-func-lines: 0

Go environment

$ go version
go version go1.24.2 darwin/arm64

Verbose output of running

$ golangci-lint migrate -v
INFO golangci-lint has version 2.1.2 built with go1.24.2 from 00a561d on 2025-04-15T13:16:26Z
INFO [config_reader] Config search paths: [./ /<path-to-repo> <redacted> /]
INFO [config_reader] Used config file .golangci.yml
INFO Validating v1 configuration file: /<path-to-repo>/.golangci.yml
INFO Saving the v1 configuration to: /<path-to-repo>/.golangci.bck.yml
WARN The configuration comments are not migrated.
WARN Details about the migration: https://golangci-lint.run/product/migration-guide/
INFO Migrating v1 configuration file: /<path-to-repo>/.golangci.yml
INFO Migration done: /<path-to-repo>/.golangci.yml
╭───────────────────────────────────────────────────────────────────────────╮
│                                                                           │
│                               We need you!                                │
│                                                                           │
│ Donations help fund the ongoing development and maintenance of this tool. │
│  If golangci-lint has been useful to you, please consider contributing.   │
│                                                                           │
│                  Donate now: https://donate.golangci.org                  │
│                                                                           │
╰───────────────────────────────────────────────────────────────────────────╯
$ echo $?
0

A minimal reproducible example or link to a public repository

.golangci.yml:

linters-settings:
  nakedret:
    max-func-lines: 0

then run golangci-lint migrate.

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

@chris-reeves chris-reeves added the bug Something isn't working label Apr 21, 2025
Copy link

boring-cyborg bot commented Apr 21, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: migration bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants