Skip to content

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

Closed
@orenl

Description

@orenl

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.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions