Skip to content

Cannot reproduce revive default behavior #2114

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

Closed
4 tasks done
weitzjdevk opened this issue Jul 13, 2021 · 2 comments
Closed
4 tasks done

Cannot reproduce revive default behavior #2114

weitzjdevk opened this issue Jul 13, 2021 · 2 comments
Labels
question Further information is requested

Comments

@weitzjdevk
Copy link

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. (https://golangci-lint.run/usage/linters/)

Description of the problem

When I use golangci-lint and using the revive plugin, I cannot reproduce the default behavior (from revive), which mimics the golint behavior that exported functions should be documented, i.e.

Error: golangci-lint + revive does not show an error.

Expected behavior: golangci-lint (with revive) should show an error, since MyPublicStruct is not documented

type struct MyPublicStruct {
}

Obeserverd behavior: No error is shown.

But revive standalone will show the error.

// MyPublicStruct .....
type struct MyPublicStruct {
}

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.41.1 built from (unknown, mod sum: "") on (unknown)

Configuration file

$ cat .golangci.yml
---
linters-settings:
  govet:
    check-shadowing: false
  gocyclo:
    min-complexity: 25
  lll:
    line-length: 200
  maligned:
    suggest-new: true
  dupl:
    threshold: 250
  goconst:
    min-len: 2
    min-occurrences: 2
  revive:
    ignore-generated-header: false
    severity: error
    confidence: 0.8
    rules:
      - name: atomic
      - name: blank-imports
      - name: confusing-naming
      - name: get-return
      - name: context-as-argument
      - name: context-keys-type
      - name: dot-imports
      - name: empty-block
      - name: error-naming
      - name: error-return
      - name: error-strings
      - name: errorf
      - 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: struct-tag
      - name: time-naming
      - name: unexported-naming
      - name: unexported-return
      - name: unhandled-error
        arguments: [
          "fmt.Printf",
          "fmt.Println",
          "fmt.Fprintf",
        ]
      - name: unreachable-code
      - name: unused-parameter
      - name: var-declaration
      - name: var-naming

run:
  skip-dirs:
    - fixtures

linters:
  enable:
    - deadcode
    - dupl
    - durationcheck
    - errcheck
    - exhaustive
    - gocognit
    - goconst
    - gocritic
    - gocyclo
    - goimports
    - gosec
    - govet
    - ineffassign
    - lll
    - misspell
    - nilerr
    - revive
    - stylecheck
    - tparallel
    - unconvert
    - unused
    - varcheck
    - whitespace


issues:
  max-per-linter: 0
  max-same: 0
  exclude:

Go environment

$ go version && go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/user/go/src/github.com/myfunkyrepo/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-build1537520533=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

Code example or link to a public repository

type struct MyPublicStruct {
   // This fails in revive, but not in golangci-lint + revive
}

// MyPublicStruct documentation...
type struct MyPublicStruct {
   // This is fine.
}
@weitzjdevk weitzjdevk added the bug Something isn't working label Jul 13, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 13, 2021

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 Jul 13, 2021
@ldez
Copy link
Member

ldez commented Jul 13, 2021

Hello,

It's expected, because by default golangci-lint excludes this kind of rule.

You have to adjust exclusions in the issues: section.

https://golangci-lint.run/usage/configuration/#config-file

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