Skip to content

golangci-lint still reports false positives even with the latest unparam version  #1379

Open
@georgysavva

Description

@georgysavva

Hi. In the previous issue #1375, I asked to update the unparam version to the latest one in golangci-lint dependencies. But it did help. it still reports the same false positives that unparam executed directly does not. I installed golangci-lint from the latest commit:

go get github.com/golangci/golangci-lint/cmd/golangci-lint@5efb842164996ba97d49d668cb4cb51c87810846
  • [+] 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).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version v1.31.1-0.20200919235159-5efb84216499 built from (unknown, mod sum: "h1:z7AU6wMUqgyuTEOPtbLarycm9FJh4JEaHGDybeVkahc=") on (unknown)
Config file
$ cat .golangci.yml
linters:
  disable-all: true
  enable:
    - bodyclose
    - deadcode
    - dogsled
    - dupl
    - errcheck
    - exhaustive
    - gochecknoinits
    - goconst
    - gocritic
    - gocyclo
    - godot
    - goerr113
    - gofumpt
    - goimports
    - golint
    - gomnd
    - gosec
    - gosimple
    - govet
    - ineffassign
    - lll
    - misspell
    - nakedret
    - noctx
    - nolintlint
    - scopelint
    - sqlclosecheck
    - staticcheck
    - structcheck
    - testpackage
    - unconvert
    - unparam
    - unused
    - varcheck

  # don't enable:
  # - asciicheck
  # - depguard
  # - exportloopref
  # - funlen
  # - gochecknoglobals
  # - gocognit
  # - godox
  # - gofmt
  # - goheader
  # - gomodguard
  # - goprintffuncname
  # - interfacer
  # - maligned
  # - nestif
  # - prealloc
  # - rowserrcheck
  # - stylecheck
  # - typecheck
  # - whitespace
  # - wsl

linters-settings:
  exhaustive:
    default-signifies-exhaustive: true
  goconst:
    min-occurrences: 2
  godot:
    check-all: true
  goimports:
    local-prefixes: github.com/georgysavva/news-app
  misspell:
    locale: US
  unparam:
    check-exported: true


issues:
  exclude-use-default: false
  exclude:
    - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)

  max-same-issues: 0
Go environment
$ go version && go env
go version go1.14 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/georgysavva/Library/Caches/go-build"
GOENV="/Users/georgysavva/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=" -mod="
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/georgysavva/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/georgysavva/repos/news-app/go.mod"
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 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gd/lq1x2k352p3d74_5zby2jjbc0000gn/T/go-build280445042=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/georgysavva/repos/news-app /Users/georgysavva/repos /Users/georgysavva /Users /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 34 linters: [bodyclose deadcode dogsled dupl errcheck exhaustive gochecknoinits goconst gocritic gocyclo godot goerr113 gofumpt goimports golint gomnd gosec gosimple govet ineffassign lll misspell nakedret noctx nolintlint scopelint sqlclosecheck staticcheck structcheck testpackage unconvert unparam unused varcheck] 
INFO [loader] Go packages loading at mode 575 (types_sizes|deps|exports_file|name|compiled_files|files|imports) took 246.016475ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 560.125µs 
INFO [linters context/goanalysis] analyzers took 10.318800553s with top 10 stages: buildir: 5.847617682s, exhaustive: 571.976189ms, inspect: 433.802669ms, fact_deprecated: 244.155438ms, printf: 196.807272ms, fact_purity: 196.373357ms, ctrlflow: 194.172168ms, buildssa: 154.770523ms, SA4011: 50.511795ms, unreachable: 46.892129ms 
INFO [linters context/goanalysis] analyzers took 49.158284ms with top 10 stages: buildir: 46.241318ms, U1000: 2.916966ms 
INFO [runner] Issues before processing: 30, after processing: 5 
INFO [runner] Processors filtering stat (out/in): path_prettifier: 30/30, exclude: 5/30, uniq_by_line: 5/5, path_shortener: 5/5, filename_unadjuster: 30/30, skip_dirs: 30/30, autogenerated_exclude: 30/30, source_code: 5/5, severity-rules: 5/5, skip_files: 30/30, identifier_marker: 30/30, diff: 5/5, max_same_issues: 5/5, path_prefixer: 5/5, sort_results: 5/5, cgo: 30/30, exclude-rules: 5/5, nolint: 5/5, max_per_file_from_linter: 5/5, max_from_linter: 5/5 
INFO [runner] processing took 1.356551ms with stages: identifier_marker: 485.031µs, path_prettifier: 278.252µs, autogenerated_exclude: 195.353µs, nolint: 154.38µs, exclude: 118.149µs, skip_dirs: 69.944µs, source_code: 30.071µs, cgo: 13.838µs, filename_unadjuster: 2.975µs, uniq_by_line: 2.148µs, path_shortener: 1.894µs, max_from_linter: 1.758µs, max_same_issues: 724ns, max_per_file_from_linter: 622ns, diff: 306ns, skip_files: 282ns, severity-rules: 238ns, exclude-rules: 238ns, sort_results: 211ns, path_prefixer: 137ns 
INFO [runner] linters took 3.540998041s with stages: goanalysis_metalinter: 3.446402066s, unused: 93.112493ms 
pkg/inmemory/inmemory.go:18:83: (*Storage).ReplaceArticles - result 0 (error) is always nil (unparam)
func (s *Storage) ReplaceArticles(_ context.Context, articles []*article.Article) error {
                                                                                  ^
pkg/inmemory/inmemory.go:37:103: (*Storage).GetArticles - result 1 (error) is always nil (unparam)
func (s *Storage) GetArticles(_ context.Context, categories, providers []string) ([]*article.Article, error) {
                                                                                                      ^
pkg/inmemory/inmemory.go:45:86: (*Storage).GetArticle - result 1 (error) is always nil (unparam)
func (s *Storage) GetArticle(_ context.Context, articleID string) (*article.Article, error) {
                                                                                     ^
pkg/inmemory/inmemory.go:52:63: (*Storage).GetCategories - result 1 (error) is always nil (unparam)
func (s *Storage) GetCategories(_ context.Context) ([]string, error) {
                                                              ^
pkg/inmemory/inmemory.go:62:62: (*Storage).GetProviders - result 1 (error) is always nil (unparam)
func (s *Storage) GetProviders(_ context.Context) ([]string, error) {
                                                             ^
INFO File cache stats: 10 entries of total size 15.0KiB 
INFO Memory: 40 samples, avg is 551.2MB, max is 941.2MB 
INFO Execution took 3.808125916s  

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions