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: exported rule does not work #1937

Closed
4 tasks done
rittneje opened this issue Apr 26, 2021 · 3 comments · Fixed by #1938
Closed
4 tasks done

revive: exported rule does not work #1937

rittneje opened this issue Apr 26, 2021 · 3 comments · Fixed by #1938
Labels
bug Something isn't working

Comments

@rittneje
Copy link

rittneje commented Apr 26, 2021

  • 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

The exported rule from revive is completely ignored. However, if I run revive directly, it is properly applied.

https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported

Also, if I use golint in my .golangci.yml instead then these lines are properly flagged.

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version v1.39.0 built from (unknown, mod sum: "h1:aAUjdBxARwkGLd5PU0vKuym281f2rFOyqh3GB4nXcq8=") on (unknown)
Config file
$ cat .golangci.yml
run:
  deadline: 5m
output:
  format: line-number
  print-issued-lines: false
  print-linter-name: true
linters-settings:
  revive:
    ignore-generated-header: true
    rules:
    - name: exported
linters:
  disable-all: true
  enable:
  - revive
issues:
  exclude-use-default: false
  max-issues-per-linter: 0
  max-same-issues: 0
Go environment
$ go version && go env
go version go1.15.11 darwin/amd64
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/tmp/.gocache"
GOENV="/Users/rittneje/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/rittneje/gotools/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/rittneje/gotools"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/rittneje/go1.15.11"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/rittneje/go1.15.11/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/Users/rittneje/revive-test/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kf/kr7_s3xx0l12zbj3jrn082hmzy5gvy/T/go-build294807898=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ /Users/rittneje/revive-test /Users/rittneje /Users / /root]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 1 linters: [revive]"
level=info msg="[loader] Go packages loading at mode 7 (files|name|compiled_files) took 33.2214ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 715.3µs"
level=info msg="[linters context/goanalysis] analyzers took 1.34ms with top 10 stages: the_only_name: 1.34ms"
level=info msg="[runner] processing took 108.8µs with stages: max_from_linter: 37.6µs, skip_dirs: 4.6µs, source_code: 4.5µs, max_same_issues: 4.5µs, nolint: 3.8µs, diff: 3.7µs, identifier_marker: 3.7µs, path_prettifier: 3.6µs, max_per_file_from_linter: 3.6µs, uniq_by_line: 3.6µs, filename_unadjuster: 3.6µs, exclude: 3.6µs, path_shortener: 3.6µs, autogenerated_exclude: 3.6µs, cgo: 3.6µs, severity-rules: 3.6µs, sort_results: 3.5µs, path_prefixer: 3.5µs, skip_files: 3.5µs, exclude-rules: 3.5µs"
level=info msg="[runner] linters took 12.9668ms with stages: revive: 12.5349ms"
level=info msg="File cache stats: 0 entries of total size 0B"
level=info msg="Memory: 2 samples, avg is 71.8MB, max is 71.8MB"
level=info msg="Execution took 54.3249ms"
Code example or link to a public repository
package sample

type Foo struct{}

func (Foo) Bar() {
}
@rittneje rittneje added the bug Something isn't working label Apr 26, 2021
@ldez
Copy link
Member

ldez commented Apr 26, 2021

Hello,

In fact, it's expected:

// By default golangci-lint ignores missing doc comments, follow same convention by removing this default rule
// Relevant issue: https://github.com/golangci/golangci-lint/issues/456
delete(conf.Rules, "package-comments")
delete(conf.Rules, "exported")

I have an idea to implement that differently.

@gandarez
Copy link
Contributor

Any update on this? It's still skipping exported rule for revive even if it's enabled.

@ldez
Copy link
Member

ldez commented Oct 13, 2022

There is no news on a closed issue.

The issue is not related to what you are looking for.


By default, golangci-lint excludes this kind of rule.

You have to adjust exclusions in the issues: section.

For example, you can do that:

issues:
  #...
  exclude-use-default: false

https://golangci-lint.run/usage/configuration/#issues-configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants