-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
area: configRelated to .golangci.yml and/or cli optionsRelated to .golangci.yml and/or cli optionsbugSomething isn't workingSomething isn't working
Description
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 (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)
Description of the problem
With the http-status-code
configured as false
for usestdlibvars
, it should not report errors for use of numeric literals such as 200
. But with the latest version of golangci-lint
, the error is still being reported. If I run the linter directly, it behaves as expected:
$ usestdlibvars -http-status-code=false ./...
<succeeds without any output>
$ usestdlibvars ./...
/.../tusestdlibvars/main.go:15:24: "200" can be replaced by http.StatusOK
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.52.2 built with go1.20.2 from da04413 on 2023-03-23T16:18:48Z
Configuration file
$ cat .golangci.toml
[linters]
disable-all = true
enable = ["usestdlibvars"]
[linters-settings]
[linters-settings.usestdlibvars]
# Suggest the use of http.StatusXX.
# covered by stylecheck ST1013.
# Default: true
http-status-code = false
Go environment
$ go version && go env
go version go1.20.3 darwin/arm64
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/skaranth/Library/Caches/go-build"
GOENV="/Users/skaranth/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/skaranth/dev/work/go/pkg/mod"
GONOPROXY="_REDACTED_"
GONOSUMDB="_REDACTED_"
GOOS="darwin"
GOPATH="/Users/skaranth/dev/work/go"
GOPRIVATE="_REDACTED_"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.3/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/.../tusestdlibvars/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zp/01m9f4ld29l4crxjfhhpnxxw0000gn/T/go-build112225028=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /.../tusestdlibvars _REDACTED_ /Users /]
INFO [config_reader] Used config file .golangci.toml
INFO [lintersdb] Active 1 linters: [usestdlibvars]
INFO [loader] Go packages loading at mode 7 (compiled_files|files|name) took 145.543792ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.47575ms
INFO [linters_context/goanalysis] analyzers took 50.583µs with top 10 stages: inspect: 43.125µs, usestdlibvars: 7.458µs
INFO [runner] Processors filtering stat (out/in): max_same_issues: 1/1, path_shortener: 1/1, severity-rules: 1/1, cgo: 1/1, skip_files: 1/1, identifier_marker: 1/1, filename_unadjuster: 1/1, autogenerated_exclude: 1/1, sort_results: 1/1, max_from_linter: 1/1, source_code: 1/1, path_prettifier: 1/1, skip_dirs: 1/1, uniq_by_line: 1/1, diff: 1/1, max_per_file_from_linter: 1/1, fixer: 1/1, path_prefixer: 1/1, exclude: 1/1, exclude-rules: 1/1, nolint: 1/1
INFO [runner] processing took 112.709µs with stages: nolint: 30.75µs, path_prettifier: 21.375µs, autogenerated_exclude: 15.833µs, identifier_marker: 14.542µs, exclude-rules: 12.291µs, source_code: 10.459µs, skip_dirs: 3.167µs, max_same_issues: 834ns, cgo: 626ns, uniq_by_line: 583ns, path_shortener: 375ns, max_from_linter: 292ns, filename_unadjuster: 291ns, severity-rules: 250ns, max_per_file_from_linter: 249ns, skip_files: 209ns, diff: 208ns, exclude: 166ns, sort_results: 84ns, fixer: 83ns, path_prefixer: 42ns
INFO [runner] linters took 14.903583ms with stages: usestdlibvars: 14.753333ms
main.go:15:24: "200" can be replaced by http.StatusOK (usestdlibvars)
if resp.StatusCode != 200 {
^
INFO File cache stats: 1 entries of total size 269B
INFO Memory: 3 samples, avg is 27.2MB, max is 27.4MB
INFO Execution took 168.664208ms
Code example or link to a public repository
package main
import (
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("https://gobyexample.com")
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
panic(resp.Status)
}
fmt.Println("Response status:", resp.Status)
}
Metadata
Metadata
Assignees
Labels
area: configRelated to .golangci.yml and/or cli optionsRelated to .golangci.yml and/or cli optionsbugSomething isn't workingSomething isn't working