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

staticcheck linter does not report S1023 and SA4011 #853

Closed
3 tasks done
egonelbre opened this issue Nov 14, 2019 · 4 comments
Closed
3 tasks done

staticcheck linter does not report S1023 and SA4011 #853

egonelbre opened this issue Nov 14, 2019 · 4 comments
Labels
bug Something isn't working dependencies Relates to an upstream dependency

Comments

@egonelbre
Copy link

Apparently S1023 and SA4011 are never being reported when you only enable staticcheck in golangci-lint. But, when you run staticcheck separately it'll report the issues.

S1023 seems to be part of gosimple, but it's weird that it's needed at all, since I would assume it's part of staticcheck already.

SA4011, of course seems to be missing entirely.


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 1.21.0 built from 645e794 on 2019-10-15T18:15:04Z
Config file
linters:
  enable:
    - staticcheck # comprehensive checks
  disable:
    - gosimple    # already part of staticcheck
  fast: false
Go environment
$ go version && go env
go version go1.13.4 windows/amd64
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=Z:\gocache
set GOENV=C:\Users\egone\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=F:\Go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=f:\tmp\testcase\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=Z:\Temp\go-build550745574=/tmp/go-build -gno-record-gcc-switches
Code
package main

import "fmt"

func main() {
	x := 0
	for {
		x++
		switch x {
		case 1:
			fmt.Println("A", x)
			break
		case 2:
			fmt.Println("B", x)
			break
		default:
			break
		}
	}
}
Verbose output of running
$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ f:\\tmp\\testcase f:\\tmp f:\\]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 9 linters: [deadcode errcheck govet ineffassign staticcheck structcheck typecheck unused varcheck]"
level=info msg="[loader] Go packages loading at mode 575 (compiled_files|exports_file|imports|name|deps|files|types_sizes) took 272.1129ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 988.4µs"
level=info msg="[runner/unused/goanalysis] analyzers took 2.0096ms with top 10 stages: buildssa: 2.0096ms, U1000: 0s"
level=info msg="[runner/goanalysis_metalinter/goanalysis] analyzers took 2.7266467s with top 10 stages: fact_purity: 639.5345ms, ctrlflow: 552.987ms, fact_deprecated: 527.7724ms, printf: 512.9744ms, buildssa: 458.8842ms, inspect: 34.4942ms, SA3000: 0s, SA4021: 0s, SA1015: 0s, SA4010: 0s"
level=info msg="[runner] Issues before processing: 3, after processing: 0"
level=info msg="[runner] Processors filtering stat (out/in): filename_unadjuster: 3/3, skip_files: 3/3, autogenerated_exclude: 3/3, identifier_marker: 3/3, path_prettifier: 3/3, skip_dirs: 3/3, cgo: 3/3, exclude: 0/3"
level=info msg="[runner] processing took 998.5µs with stages: autogenerated_exclude: 998.5µs, exclude-rules: 0s, max_same_issues: 0s, source_code: 0s, skip_files: 0s, filename_unadjuster: 0s, exclude: 0s, nolint: 0s, diff: 0s, max_per_file_from_linter: 0s, max_from_linter: 0s, cgo: 0s, uniq_by_line: 0s, identifier_marker: 0s, path_shortener: 0s, skip_dirs: 0s, path_prettifier: 0s"
level=info msg="[runner] linters took 1.6427939s with stages: goanalysis_metalinter: 1.5437952s, unused: 80.0014ms"
level=info msg="File cache stats: 0 entries of total size 0B"
level=info msg="Memory: 21 samples, avg is 81.8MB, max is 135.9MB"
level=info msg="Execution took 1.9921699s"
@tpounds tpounds added the bug Something isn't working label Nov 15, 2019
@pierrre
Copy link
Contributor

pierrre commented Nov 20, 2019

A probable cause: golangci-lint currently uses an "old" version of staticcheck.
See #357
(I could be wrong)

@tpounds tpounds added the dependencies Relates to an upstream dependency label Dec 30, 2019
@sayboras
Copy link
Member

sayboras commented May 24, 2020

@egonelbre this should be fixed as part of upgrade of honnef.co/go/tools #1145

@KenjiTakahashi
Copy link

The update is in now, but the issue is still here as well. Tested with 1.28.1.

@ldez
Copy link
Member

ldez commented Mar 24, 2021

In S1023 the prefix S means Simple, so S1023 is reported by gosimple.

In the code, gosimple and staticcheck are 2 differents set of linters:

SA4011 is missing because it's a part of the default exclusions defined in golangci-lint

{
ID: "EXC0005",
Pattern: "ineffective break statement. Did you mean to break out of the outer loop",
Linter: "staticcheck",
Why: "Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore",
},

@ldez ldez closed this as completed Mar 24, 2021
mihaitodor added a commit to redpanda-data/connect that referenced this issue Dec 9, 2023
I noticed this by running [staticcheck](https://staticcheck.dev).
Unfortunately, golangci-lint is still using a deprecated version
of this linter. See [here](golangci/golangci-lint#853)
and [here](golangci/golangci-lint#357).

Signed-off-by: Mihai Todor <[email protected]>
harshit-sp pushed a commit to harshit-sp/benthos that referenced this issue Feb 4, 2024
I noticed this by running [staticcheck](https://staticcheck.dev).
Unfortunately, golangci-lint is still using a deprecated version
of this linter. See [here](golangci/golangci-lint#853)
and [here](golangci/golangci-lint#357).

Signed-off-by: Mihai Todor <[email protected]>
Signed-off-by: harshit-sp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Relates to an upstream dependency
Projects
None yet
Development

No branches or pull requests

6 participants