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 does not exclude some of the exported comment lint. #2004

Closed
4 tasks done
buzztaiki opened this issue May 20, 2021 · 2 comments · Fixed by #2005
Closed
4 tasks done

revive does not exclude some of the exported comment lint. #2004

buzztaiki opened this issue May 20, 2021 · 2 comments · Fixed by #2005
Assignees
Labels
bug Something isn't working

Comments

@buzztaiki
Copy link

  • 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

revive does not exclude some of the exported comment lint. but golint exclude same one.

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.40.1 built from 625445b1 on 2021-05-14T11:44:45Z
Config file
$ cat .golangci.yml
linters:
  enable:
    - revive
Go environment
$ go version && go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/taiki/.cache/go-build"
GOENV="/home/taiki/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/taiki/dev/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/taiki/dev"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/taiki/tmp/golangci-revive/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build350676579=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/taiki/tmp/golangci-revive /home/taiki/tmp /home/taiki /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 11 linters: [deadcode errcheck gosimple govet ineffassign revive staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (exports_file|files|types_sizes|compiled_files|deps|imports|name) took 76.539641ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 113.41µs
INFO [linters context/goanalysis] analyzers took 8.137345ms with top 10 stages: the_only_name: 3.743804ms, nilness: 1.860044ms, fact_deprecated: 326.681µs, buildir: 274.052µs, typedness: 223.17µs, ctrlflow: 150.564µs, SA5012: 143.803µs, printf: 142.874µs, fact_purity: 132.593µs, unused: 94.732µs
INFO [runner] Processors filtering stat (out/in): path_prettifier: 2/2, autogenerated_exclude: 2/2, nolint: 2/2, max_from_linter: 2/2, path_prefixer: 2/2, skip_dirs: 2/2, exclude: 2/2, diff: 2/2, max_per_file_from_linter: 2/2, max_same_issues: 2/2, source_code: 2/2, path_shortener: 2/2, severity-rules: 2/2, filename_unadjuster: 2/2, cgo: 2/2, skip_files: 2/2, identifier_marker: 2/2, exclude-rules: 2/2, uniq_by_line: 2/2, sort_results: 2/2
INFO [runner] processing took 397.27µs with stages: exclude-rules: 150.264µs, identifier_marker: 98.618µs, nolint: 42.631µs, autogenerated_exclude: 30.98µs, path_prettifier: 26.047µs, source_code: 21.688µs, skip_dirs: 11.265µs, max_same_issues: 3.73µs, uniq_by_line: 3.101µs, cgo: 1.91µs, path_shortener: 1.48µs, max_from_linter: 1.446µs, filename_unadjuster: 1.407µs, max_per_file_from_linter: 762ns, skip_files: 383ns, exclude: 351ns, path_prefixer: 318ns, diff: 310ns, severity-rules: 299ns, sort_results: 280ns
INFO [runner] linters took 22.77286ms with stages: goanalysis_metalinter: 21.742262ms
a.go:4:2: exported: exported const C should have comment (or a comment on this block) or be unexported (revive)
        C = "x"
        ^
a.go:7:1: exported: comment on exported function F should be of the form "F ..." (revive)
// a function
^
INFO File cache stats: 1 entries of total size 83B
INFO Memory: 3 samples, avg is 71.2MB, max is 71.3MB
INFO Execution took 120.633263ms
Code example or link to a public repository
package example

const (
	C = "x"
)

// a function
func F() string {
	return "F"
}

It looks like the default exlude rule doesn't cover some cases.

  • ID: "EXC0012",
    Pattern: "exported (method|function|type|const) (.+) should have comment or be unexported",
    Linter: "revive",
    Why: "Annoying issue about not having a comment. The rare codebase has such comments",
    },
    {
    ID: "EXC0013",
    Pattern: `package comment should be of the form "Package (.+) ..."`,
    Linter: "revive",
    Why: "Annoying issue about not having a comment. The rare codebase has such comments",
    },
  • https://github.com/mgechev/revive/blob/master/rule/exported.go
@buzztaiki buzztaiki added the bug Something isn't working label May 20, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented May 20, 2021

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

@buzztaiki
Copy link
Author

I think that #1938 breaks backward compatibility.

@ldez ldez self-assigned this May 20, 2021
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.

2 participants