Skip to content

nolintlint conflicts with new go1.19 gofmt #3073

Closed
@dnephin

Description

@dnephin

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

I just upgraded to golangci-lint v1.48.0.

It seems that gofmt can now conflict with nolintlint. For example, I have this code:

//nolint:maintidx
func something() { ... }

When I run golangci-lint run the gofmt linter complains and says the file is not formatted properly.

filename:line: File is not `gofmt`-ed with `-s` (gofmt)
//nolint: maintidx

If I fix it (using --fix or manually), and run again, I get

filename:line: directive `// nolint: maintidx` should be written without leading space as `//nolint: maintidx` (nolintlint)
// nolint: maintidx

I have other //nolint: directives that are not impacted. It seems to be only this one, because it is on a function definition instead of in a function block. I think gofmt is considering it a godoc comment (even though the function is not exported).

Version of golangci-lint

$ golangci-lint --version
# Paste output here

Configuration file

$ cat .golangci.yml
# paste output here

Go environment

golangci-lint v1.48.0 golang v1.18.1

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

Code example or link to a public repository

https://github.com/gotestyourself/gotest.tools/blob/fac3030b84c98b640417ebd23001567d5f3501f7/assert/cmd/gty-migrate-from-testify/migrate.go#L144-L145

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions