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

Private linters must be explicitly enabled in .golangci.yml to make effect #1335

Closed
3 tasks done
chenlujjj opened this issue Aug 26, 2020 · 3 comments · Fixed by #3911
Closed
3 tasks done

Private linters must be explicitly enabled in .golangci.yml to make effect #1335

chenlujjj opened this issue Aug 26, 2020 · 3 comments · Fixed by #3911
Labels
area: docs linter: custom About custom/private linters

Comments

@chenlujjj
Copy link

Thank you for creating the issue!

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

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version (devel) built from (unknown, mod sum: "") on (unknown)

I built the golangci-lint binary from souce code (tag: v1.30.0)

Config file
$ cat .golangci.yml
linters-settings:
 custom:
  example:
   path: ./example.so
   description: The description of the linter
   # original-url: github.com/golangci/example-linter
Go environment
$ go version && go env
go version go1.14.3 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/chenluxin/go/bin"
GOCACHE="/Users/chenluxin/Library/Caches/go-build"
GOENV="/Users/chenluxin/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/chenluxin/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/chenluxin/Codes/golangci-lint/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yw/7fx03kmn3qzf1rtwvz87qqtm0000gn/T/go-build461312627=/tmp/go-build -gno-record-gcc-switches -fno-common"

I tried to follow the add private linter guide and found that if I didn't explicitly enable the custom plugin, then the linter wont take effect:

> ./golangci-lint linters --verbose
INFO [config_reader] Config search paths: [./ /Users/chenluxin/Codes/example-plugin-linter /Users/chenluxin/Codes /Users/chenluxin /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO Loaded ./example.so: example
Enabled by your configuration linters:
deadcode: Finds unused code [fast: true, auto-fix: false]
errcheck: Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: true, auto-fix: false]
gosimple (megacheck): Linter for Go source code that specializes in simplifying a code [fast: true, auto-fix: false]
govet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false]
ineffassign: Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
staticcheck (megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: true, auto-fix: false]
structcheck: Finds unused struct fields [fast: true, auto-fix: false]
typecheck: Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false]
unused (megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
varcheck: Finds unused global variables and constants [fast: true, auto-fix: false]

...

After I modified the config file as below:

$ cat .golangci.yml
linters:
  enable:
    - example

linters-settings:
 custom:
  example:
   path: ./example.so
   description: The description of the linter
   # original-url: github.com/golangci/example-linter

The private linter works:

./golangci-lint linters --verbose
INFO [config_reader] Config search paths: [./ /Users/chenluxin/Codes/example-plugin-linter /Users/chenluxin/Codes /Users/chenluxin /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO Loaded ./example.so: example
Enabled by your configuration linters:
deadcode: Finds unused code [fast: true, auto-fix: false]
errcheck: Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: true, auto-fix: false]
**example: The description of the linter [fast: true, auto-fix: false]**
gosimple (megacheck): Linter for Go source code that specializes in simplifying a code [fast: true, auto-fix: false]
govet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false]
ineffassign: Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
staticcheck (megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: true, auto-fix: false]
structcheck: Finds unused struct fields [fast: true, auto-fix: false]
typecheck: Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false]
unused (megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
varcheck: Finds unused global variables and constants [fast: true, auto-fix: false]
...

This is different from the guide:

Custom linters are enabled by default

Is there something wrong here ?

@chenlujjj chenlujjj added the bug Something isn't working label Aug 26, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 26, 2020

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

@draveness
Copy link

I met the same problem with 1.31.0 master branch, enable-all:true does not work at all. We need to enable them explicitly

@stale
Copy link

stale bot commented Mar 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docs linter: custom About custom/private linters
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants