Skip to content

Inconsistent behavior of "revive"'s "confusing-naming" linter when used together with "nolintlint" #3476

Closed
@leonklingele

Description

@leonklingele

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 (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

It seems like the confusing-naming linter of revive is behaving inconsistently when used in conjunction with the "nolintlint" linter, based on the order of which the source files are parsed / analyzed.

See the code example / steps to reproduce below.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.1 built from v1.50.1 on 19700101-00:00:00

Configuration file

$ cat .golangci.yml
run:
  skip-dirs:
    - internal

linters-settings:
  revive:
    rules:
      - name: confusing-naming
        disabled: false

linters:
  disable-all: true
  enable:
    - nolintlint
    - revive

Go environment

$ go version && go env
go version go1.19.4 linux/amd64

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
[..]
router.go:148:54: directive `//nolint:revive` is unused for linter "revive" (nolintlint)
func (app *App) handler(rctx *fasthttp.RequestCtx) { //nolint:revive

Code example or link to a public repository

$ git clone --depth 1 --b https://github.com/leonklingele/fiber
$ cd fiber

$ golangci-lint run -v
[..]
router.go:148:17: confusing-naming: Method 'handler' differs only by capitalization to method 'Handler' in app.go (revive)
func (app *App) handler(rctx *fasthttp.RequestCtx) {

# Add a "//nolint:revive" to that line (router.go:148:17) and run again:

$ golangci-lint run -v
[..]
app.go:829:17: confusing-naming: Method 'Handler' differs only by capitalization to method 'handler' in router.go (revive)
func (app *App) Handler() fasthttp.RequestHandler {
               ^
router.go:148:54: directive `//nolint:revive` is unused for linter "revive" (nolintlint)
func (app *App) handler(rctx *fasthttp.RequestCtx) { //nolint:revive

# Oh well, now it's complaining about the same issue but in app.go this time.
# Also add a "//nolint:revive" in that line (app.go:829:17) and run again:

$ golangci-lint run -v
[..]
router.go:148:54: directive `//nolint:revive` is unused for linter "revive" (nolintlint)
func (app *App) handler(rctx *fasthttp.RequestCtx) { //nolint:revive

# There seems to be no way to get rid of both errors.

Metadata

Metadata

Assignees

Labels

area: nolintRelated to nolint directive and nolintlintbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions