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

staticchecks errors are not reported #2049

Closed
4 tasks done
arxeiss opened this issue Jun 13, 2021 · 4 comments
Closed
4 tasks done

staticchecks errors are not reported #2049

arxeiss opened this issue Jun 13, 2021 · 4 comments
Labels
question Further information is requested

Comments

@arxeiss
Copy link

arxeiss commented Jun 13, 2021

  • 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

I have enabled stylecheck and staticcheck but errors from those linters are not reported. But when I tried to run staticcheck directly, errors are reported.

When I run staticcheck ./... with following staticcheck.conf file, I got this error:

ast/astutils/matchers.go:67:1: comment on exported function MatchVariableNode should be of the form "MatchVariableNode ..." (ST1020)
checks = ["all", "-ST1000", "ST1003", "ST1016", "ST1020", "ST1021", "ST1022", "ST1023"]
http_status_code_whitelist = ["200", "400", "404", "500"]
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version v1.40.1 built from (unknown, mod sum: "h1:pBrCqt9BgI9LfGCTKRTSe1DfMjR6BkOPERPaXJYXA6Q=") on (unknown)
Config file
---
linters:
  enable:
    # By Default
    - deadcode
    - errcheck
    - gosimple
    - govet
    - ineffassign
    - staticcheck
    - structcheck
    - typecheck
    - unused
    - varcheck
    # Extra
    - asciicheck
    - cyclop
    - gocritic
    - gofmt
    - goimports
    - gosec
    - ifshort
    - lll
    - prealloc
    - stylecheck
    - unconvert
    - whitespace

linters-settings:
  lll:
    line-length: 120
    tab-width: 4
  goimports:
    local-prefixes: github.com/arxeiss/go-expression-calculator
  cyclop:
    max-complexity: 15
  staticcheck:
    go: "1.15"
    checks: ["all", "ST1000", "ST1003", "ST1016", "ST1020", "ST1021", "ST1022"]
  stylecheck:
    go: "1.15"
    checks: ["all", "ST1000", "ST1003", "ST1016", "ST1020", "ST1021", "ST1022"]
Go environment
$ go version && go env
go version go1.16.4 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pavel/.cache/go-build"
GOENV="/home/pavel/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pavel/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pavel/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.4"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/pavel/Projects/go-expression-calculator/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-build2099628751=/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/pavel/Projects/go-expression-calculator /home/pavel/Projects /home/pavel /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 22 linters: [asciicheck cyclop deadcode errcheck gocritic gofmt goimports gosec gosimple govet ifshort ineffassign lll prealloc staticcheck structcheck stylecheck typecheck unconvert unused varcheck whitespace] 
INFO [loader] Go packages loading at mode 575 (deps|imports|name|compiled_files|exports_file|files|types_sizes) took 417.000733ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.720999ms 
INFO [linters context/goanalysis] analyzers took 21.511864334s with top 10 stages: buildir: 12.806920456s, inspect: 1.414562645s, nilness: 607.938652ms, fact_purity: 569.27192ms, unconvert: 510.018044ms, ctrlflow: 309.083567ms, fact_deprecated: 267.834694ms, SA5012: 207.484293ms, printf: 205.213689ms, typedness: 135.840184ms 
INFO [runner] Issues before processing: 14, after processing: 0 
INFO [runner] Processors filtering stat (out/in): path_prettifier: 14/14, skip_files: 14/14, skip_dirs: 14/14, exclude-rules: 1/14, cgo: 14/14, filename_unadjuster: 14/14, autogenerated_exclude: 14/14, identifier_marker: 14/14, exclude: 14/14, nolint: 0/1 
INFO [runner] processing took 1.945526ms with stages: exclude-rules: 707.244µs, nolint: 390.85µs, identifier_marker: 368.596µs, path_prettifier: 226.327µs, autogenerated_exclude: 182.129µs, skip_dirs: 58.827µs, cgo: 3.826µs, filename_unadjuster: 2.794µs, max_same_issues: 1.019µs, uniq_by_line: 640ns, diff: 463ns, source_code: 431ns, max_from_linter: 400ns, skip_files: 362ns, path_shortener: 303ns, severity-rules: 301ns, exclude: 282ns, sort_results: 258ns, max_per_file_from_linter: 256ns, path_prefixer: 218ns 
INFO [runner] linters took 8.461816362s with stages: goanalysis_metalinter: 8.459776403s 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 90 samples, avg is 387.0MB, max is 608.0MB 
INFO Execution took 8.888381835s  
Code example or link to a public repository
// MatchXXX expects types.GomegaMatcher or passed name will be compared with gomega.Equal
func MatchVariableNode(name interface{}) types.GomegaMatcher {
	return &variableMatcher{
		name: name,
	}
}
@arxeiss arxeiss added the bug Something isn't working label Jun 13, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 13, 2021

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

@ldez
Copy link
Member

ldez commented Jun 13, 2021

Hello,

FYI, the checks options for staticcheck and stylecheck are not available in v1.40.1, they will be available in the next version (v1.41.0)

Can you provide a reproducible example?

@ldez ldez added feedback required Requires additional feedback question Further information is requested and removed bug Something isn't working labels Jun 13, 2021
@ldez
Copy link
Member

ldez commented Jun 13, 2021

I created a reproducible example:

package sandbox

import "github.com/onsi/gomega/types"

type variableMatcher struct {
	name interface{}
}

func (v variableMatcher) Match(actual interface{}) (success bool, err error) {
	panic("implement me")
}

func (v variableMatcher) FailureMessage(actual interface{}) (message string) {
	panic("implement me")
}

func (v variableMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	panic("implement me")
}

// MatchXXX expects types.GomegaMatcher or passed name will be compared with gomega.Equal
func MatchVariableNode(name interface{}) types.GomegaMatcher {
	return &variableMatcher{
		name: name,
	}
}

The rule ST1020 is globally excluded by golangci-lint like the other rules on comments.

With the next release, you just have to add the following line in your configuration.

issues:
  exclude-use-default: false

I repeat: the checks options for staticcheck and stylecheck are not available in v1.40.1, they will be available in the next version (v1.41.0)

@ldez ldez closed this as completed Jun 13, 2021
@ldez ldez removed the feedback required Requires additional feedback label Jun 13, 2021
@arxeiss
Copy link
Author

arxeiss commented Jun 13, 2021

I added the exclude-use-default: false and it started to work. So it was merged into 1.40.1 as well? Because it is also in documentation already.

Edit: I see, so it is ignoring checks, but otherwise it works.

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