Skip to content
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

Revive doesn't complain about unused parameters #3653

Closed
4 tasks done
walles opened this issue Mar 3, 2023 · 4 comments
Closed
4 tasks done

Revive doesn't complain about unused parameters #3653

walles opened this issue Mar 3, 2023 · 4 comments
Labels
question Further information is requested

Comments

@walles
Copy link

walles commented Mar 3, 2023

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

golangci-lint's Revive documentation says unused-parameter is not disabled:

      ...
      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
      - name: unused-parameter
        severity: warning
        disabled: false
      ...

But enabling Revive and running it on an example program gives me no unused-parameter diagnostics.

I would like to have Revive tell me about unused parameters.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.51.2 built from 3e8facb on 2023-02-19T20:54:52Z

Configuration file

$ cat .golangci.yml
cat: .golangci.yml: No such file or directory

Go environment

$ go version && go env
go version go1.20.1 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/johan/Library/Caches/go-build"
GOENV="/Users/johan/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/johan/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/johan/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.20.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.20.1/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cg/d7qzk4s13s9c8t49t3txdjpr0000gn/T/go-build1895242244=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
/tmp $ golangci-lint cache clean && golangci-lint run -v -E revive pajj.go
INFO [config_reader] Config search paths: [./ /tmp / /Users/johan]
INFO [lintersdb] Active 8 linters: [errcheck gosimple govet ineffassign revive staticcheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (deps|files|compiled_files|imports|name|types_sizes|exports_file) took 146.273377ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 260.315µs
INFO [linters_context/goanalysis] analyzers took 1.386377756s with top 10 stages: buildir: 919.560591ms, the_only_name: 91.219139ms, inspect: 61.130495ms, fact_purity: 50.928733ms, printf: 50.508523ms, SA5012: 49.181698ms, ctrlflow: 46.243002ms, nilness: 39.059048ms, fact_deprecated: 36.182834ms, typedness: 33.668338ms
INFO [runner] Issues before processing: 1, after processing: 0
INFO [runner] Processors filtering stat (out/in): path_prettifier: 1/1, skip_dirs: 1/1, autogenerated_exclude: 1/1, identifier_marker: 1/1, exclude-rules: 0/1, cgo: 1/1, filename_unadjuster: 1/1, skip_files: 1/1, exclude: 1/1
INFO [runner] processing took 278.047µs with stages: identifier_marker: 71.354µs, autogenerated_exclude: 70.216µs, path_prettifier: 60.718µs, exclude-rules: 39.897µs, skip_dirs: 23.063µs, filename_unadjuster: 3.741µs, nolint: 2.917µs, cgo: 1.552µs, max_same_issues: 707ns, skip_files: 452ns, uniq_by_line: 446ns, diff: 438ns, source_code: 428ns, max_from_linter: 408ns, severity-rules: 370ns, path_shortener: 303ns, exclude: 298ns, sort_results: 294ns, path_prefixer: 245ns, max_per_file_from_linter: 200ns
INFO [runner] linters took 1.121494494s with stages: goanalysis_metalinter: 1.121028236s
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 14 samples, avg is 164.3MB, max is 272.2MB
INFO Execution took 1.281886455s
/tmp $

Code example or link to a public repository

package main

import "fmt"

func hello(unused string) {
	fmt.Println("Hello")
}

func main() {
	hello("unused")
}
@walles walles added the bug Something isn't working label Mar 3, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 3, 2023

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

@ldez ldez added question Further information is requested and removed bug Something isn't working labels Mar 3, 2023
@ldez
Copy link
Member

ldez commented Mar 3, 2023

Hello,

the default rule set for revive is:

  • VarDeclarationsRule
  • PackageCommentsRule
  • DotImportsRule
  • BlankImportsRule
  • ExportedRule
  • VarNamingRule
  • IndentErrorFlowRule
  • RangeRule
  • ErrorfRule
  • ErrorNamingRule
  • ErrorStringsRule
  • ReceiverNamingRule
  • IncrementDecrementRule
  • ErrorReturnRule
  • UnexportedReturnRule
  • TimeNamingRule
  • ContextKeysType
  • ContextAsArgumentRule

It's the same rule set as the standalone binary of revive.

The rule UnusedParamRule is not in this default rule set.

So you have to enable this rule.

The documentation about the disabled option for revive is not correlated to the default rule set (inside the section you can see that disabled is always set to false).

@ldez ldez closed this as completed Mar 3, 2023
@walles
Copy link
Author

walles commented Mar 3, 2023

Thanks for the quick response!

Opened a related PR for upstream: mgechev/revive#799

@ldez
Copy link
Member

ldez commented Mar 3, 2023

A recommendation doesn't mean that must be the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants