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 linters "exported" and "package-comments" do not work #3987

Closed
5 tasks done
orenl opened this issue Aug 5, 2023 · 3 comments
Closed
5 tasks done

Revive linters "exported" and "package-comments" do not work #3987

orenl opened this issue Aug 5, 2023 · 3 comments
Labels
question Further information is requested

Comments

@orenl
Copy link

orenl commented Aug 5, 2023

Welcome

Description of the problem

With "revive" linter enabled, the checkers for "exported" and "package-comments" do not work. When running the standalone linter, same version, on the same source, they work correctly.

The problem occurs both with the default "revive" configuration (i.e. no mention of "revive" in "linters-settings"), and with the recommended "revive" configuration (from their github repository).

Running golangci-lint -config .golangci.yml /tmp/sample/a.go does not emit any complaints (with or without the "linters-settings" section).

Running revive /tmp/sample/a.go emits the following output (with or without the recommended configuration from the projects Github page):

/tmp/package/a.go:3:7: exported const Public should have comment or be unexported
/tmp/package/a.go:1:1: should have a package comment

Version of golangci-lint

$ golangci-lint --version
# Paste output here
golangci-lint has version v1.53.3 built with go1.20.7 from (unknown, mod sum: "h1:CUcRafczT4t1F+mvdkUm6KuOpxUZTl0yWN/rSU6sSMo=") on (unknown)

Configuration

# paste configuration file or CLI flags here
linters:
  enable:
    # Drop-in replacement of `golint`.
    - revive

linters-settings:
  revive:
    ignoreGeneratedHeader: false
    severity: error
    confidence: 0.7
    errorCode: 1
    warningCode: 1
    rules:
      - name: blank-imports
      - name: context-as-argument
      - name: context-keys-type
      - name: dot-imports
      - name: empty-block
      - name: errorf
      - name: error-return
      - name: error-strings
      - name: error-naming
      - name: exported
      - name: if-return
      - name: increment-decrement
      - name: indent-error-flow
      - name: package-comments
      - name: range
      - name: receiver-naming
      - name: redefines-builtin-id
      - name: superfluous-else
      - name: time-naming
      - name: unexported-return
      - name: unused-parameter
      - name: unreachable-code
      - name: var-declaration
      - name: var-naming

Go environment

$ go version && go env
# paste output here
go version go1.20.7 linux/amd64
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/tmp/sample/gocache"
GOENV="/home/orenl/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/tmp/sample/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/tmp/sample/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go-1.20.7"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go-1.20.7/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.7"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/sample/go.mod"
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1240614369=/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: [./ /tmp/sample/src /tmp/sample /tmp / /home/orenl] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 45 linters: [asasalint asciicheck bidichk bodyclose contextcheck durationcheck errcheck errname errorlint exportloopref gocritic godot gofmt gofumpt goimports gomoddirectives gosec gosimple govet ineffassign misspell nakedret nilerr nilnil noctx nolintlint prealloc predeclared promlinter reassign revive rowserrcheck sqlclosecheck staticcheck stylecheck tagliatelle tenv testableexamples thelper tparallel unconvert unparam unused usestdlibvars wastedassign] 
INFO [loader] Using build tags: [integration]     
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|imports|name|types_sizes|exports_file|files) took 142.763573ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.121987ms

Code example or link to a public repository

package blah

const Public = 0

Validation

  • Yes, I've included all information above (version, config, etc.).
@orenl orenl added the bug Something isn't working label Aug 5, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 5, 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 Aug 5, 2023
@ldez
Copy link
Member

ldez commented Aug 5, 2023

Hello,

Those reports are ignored by default: EXC0014 and EXC0015.
It was flagged as "Annoying issue about not having a comment. The rare codebase has such comments".

To show the report, you have to disable the default exclusions:

issues:
  exclude-use-default: false

or you have to disable this specific exclusion rule:

issues:
  include:
    - EXC0014
    - EXC0015

It will be changed at some point: #456 (comment)

@ldez ldez closed this as completed Aug 5, 2023
@orenl
Copy link
Author

orenl commented Aug 5, 2023

Thanks for the quick resolution!

For the record, it's EXC0012 and EXC0015.

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