usestdlibvars: fix configuration (#3797)
This commit is contained in:
parent
f64889463f
commit
cec16b68ab
@ -122,6 +122,10 @@ var defaultLintersSettings = LintersSettings{
|
||||
Unparam: UnparamSettings{
|
||||
Algo: "cha",
|
||||
},
|
||||
UseStdlibVars: UseStdlibVarsSettings{
|
||||
HTTPMethod: true,
|
||||
HTTPStatusCode: true,
|
||||
},
|
||||
Varnamelen: VarnamelenSettings{
|
||||
MaxDistance: 5,
|
||||
MinNameLength: 3,
|
||||
|
@ -252,6 +252,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
||||
thelperCfg = &m.cfg.LintersSettings.Thelper
|
||||
unparamCfg = &m.cfg.LintersSettings.Unparam
|
||||
unusedCfg = new(config.StaticCheckSettings)
|
||||
usestdlibvars = &m.cfg.LintersSettings.UseStdlibVars
|
||||
varcheckCfg = &m.cfg.LintersSettings.Varcheck
|
||||
varnamelenCfg = &m.cfg.LintersSettings.Varnamelen
|
||||
whitespaceCfg = &m.cfg.LintersSettings.Whitespace
|
||||
|
12
test/testdata/configs/usestdlibvars_non_default.yml
vendored
Normal file
12
test/testdata/configs/usestdlibvars_non_default.yml
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
linters-settings:
|
||||
usestdlibvars:
|
||||
http-method: false
|
||||
http-status-code: false
|
||||
time-weekday: true
|
||||
time-month: true
|
||||
time-layout: true
|
||||
crypto-hash: true
|
||||
default-rpc-path: true
|
||||
sql-isolation-level: true
|
||||
tls-signature-scheme: true
|
||||
constant-kind: true
|
54
test/testdata/usestdlibvars_non_default.go
vendored
Normal file
54
test/testdata/usestdlibvars_non_default.go
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
//golangcitest:args -Eusestdlibvars
|
||||
//golangcitest:config_path testdata/configs/usestdlibvars_non_default.yml
|
||||
package testdata
|
||||
|
||||
import "net/http"
|
||||
|
||||
func _200() {
|
||||
_ = 200
|
||||
}
|
||||
|
||||
func _200_1() {
|
||||
var w http.ResponseWriter
|
||||
w.WriteHeader(200)
|
||||
}
|
||||
|
||||
const (
|
||||
_ = "Bool" // want `"Bool" can be replaced by constant\.Bool\.String\(\)`
|
||||
_ = "Complex" // want `"Complex" can be replaced by constant\.Complex\.String\(\)`
|
||||
)
|
||||
|
||||
const (
|
||||
_ = "BLAKE2b-256" // want `"BLAKE2b-256" can be replaced by crypto\.BLAKE2b_256\.String\(\)`
|
||||
_ = "BLAKE2b-384" // want `"BLAKE2b-384" can be replaced by crypto\.BLAKE2b_384\.String\(\)`
|
||||
)
|
||||
|
||||
const (
|
||||
_ = "/_goRPC_" // want `"/_goRPC_" can be replaced by rpc\.DefaultRPCPath`
|
||||
_ = "/debug/rpc" // want `"/debug/rpc" can be replaced by rpc\.DefaultDebugPath`
|
||||
)
|
||||
|
||||
const (
|
||||
_ = "Read Committed" // want `"Read Committed" can be replaced by sql\.LevelReadCommitted\.String\(\)`
|
||||
_ = "Read Uncommitted" // want `"Read Uncommitted" can be replaced by sql\.LevelReadUncommitted\.String\(\)`
|
||||
)
|
||||
|
||||
const (
|
||||
_ = "01/02 03:04:05PM '06 -0700" // want `"01/02 03:04:05PM '06 -0700" can be replaced by time\.Layout`
|
||||
_ = "02 Jan 06 15:04 -0700" // want `"02 Jan 06 15:04 -0700" can be replaced by time\.RFC822Z`
|
||||
)
|
||||
|
||||
const (
|
||||
_ = "April" // want `"April" can be replaced by time\.April\.String\(\)`
|
||||
_ = "August" // want `"August" can be replaced by time\.August\.String\(\)`
|
||||
)
|
||||
|
||||
const (
|
||||
_ = "Friday" // want `"Friday" can be replaced by time\.Friday\.String\(\)`
|
||||
_ = "Monday" // want `"Monday" can be replaced by time\.Monday\.String\(\)`
|
||||
)
|
||||
|
||||
const (
|
||||
_ = "ECDSAWithP256AndSHA256" // want `"ECDSAWithP256AndSHA256" can be replaced by tls\.ECDSAWithP256AndSHA256\.String\(\)`
|
||||
_ = "ECDSAWithP384AndSHA384" // want `"ECDSAWithP384AndSHA384" can be replaced by tls\.ECDSAWithP384AndSHA384\.String\(\)`
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user