Skip to content

nolintlint: reports false positive warnings about used nolint directive #3228

Closed

Description

@fho

Welcome

Description of the problem

We have staticcheck and nonolint enabled.
Sometimes in our CI builds golangci-lint reports a false warnings from nonolint about unused nolint:staticcheck comments.
All warnings that I checked are wrong, the //nolint:staticcheck directives always silence existing deprecation warnings from staticcheck.

I was not able to reproduce this issue.
In CI we reuse the golangci-lint and go cache when running checks on different branches.
It can happen that the same cache was used previously with older go and/or golangci-lint versions.

I believe #1940 (comment) refers to the same issue.

Version of golangci-lint

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

Configuration file

Details
$ cat .golangci.yml
run:
  concurrency: 2
  deadline: 5m

linters:
  disable-all: true
  enable:
    - depguard
    - errcheck
    - exportloopref
    - goimports
    - goprintffuncname
    - ineffassign
    - misspell
    - nolintlint
    - revive
    - rowserrcheck
    - staticcheck
    - typecheck
    - unconvert
    - unused
    - vet

issues:
  exclude-use-default: false

Go environment

Details
$ go version && go env
[/src/go/code/orders]$ go version && go env
go version go1.19.1 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN="/usr/local/bin"
GOCACHE="/var/cache/go-build"
GOENV="/tmp/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-tags=timetzdata -trimpath"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/var/cache/go-modcache"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/tmp/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/src/go/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1328424340=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

N/A

Code example or link to a public repository

Example case, output from golangci-lint:

[..]/itemdetails.go:36:32: directive `//nolint:staticcheck // Description field is deprecated` is unused for linter "staticcheck" (nolintlint)
		return item.Description, nil //nolint:staticcheck // Description field is deprecated

The referenced Description field has a deprecation comment set:

// Deprecated: Do not use.
Description      string                 `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`

Activity

  1. added
    bugSomething isn't working
    on Sep 21, 2022
  2. ldez commented on Sep 21, 2022

    @ldez
    Member

    Hello,

    I change some elements related to facts (they are used by staticcheck) maybe the problem will be fixed with the next release (v1.50.0)

  3. fho commented on Nov 1, 2022

    @fho
    Author

    The issue happend again with golangci-lint 1.50.0.

  4. nocive commented on Mar 3, 2023

    @nocive
  5. iwata commented on Oct 11, 2023

    @iwata

    Happened with golangci-lint v1.54.2, too.

  6. 56 remaining items

  7. rostislaved commented on Mar 12, 2026

    @rostislaved
  8. rostislaved commented on Mar 13, 2026

    @rostislaved
  9. silverwind commented on May 4, 2026

    @silverwind
  10. bombsimon commented on May 4, 2026

    @bombsimon
  11. silverwind commented on May 4, 2026

    @silverwind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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