File tree Expand file tree Collapse file tree 6 files changed +48
-5
lines changed Expand file tree Collapse file tree 6 files changed +48
-5
lines changed Original file line number Diff line number Diff line change @@ -838,7 +838,7 @@ type StaticCheckSettings struct {
838838}
839839
840840func (s * StaticCheckSettings ) HasConfiguration () bool {
841- return len ( s .Initialisms ) > 0 || len ( s .HTTPStatusCodeWhitelist ) > 0 || len ( s .DotImportWhitelist ) > 0 || len ( s .Checks ) > 0
841+ return s .Initialisms == nil || s .HTTPStatusCodeWhitelist == nil || s .DotImportWhitelist == nil || s .Checks == nil
842842}
843843
844844type TagAlignSettings struct {
Original file line number Diff line number Diff line change @@ -79,19 +79,19 @@ func createConfig(settings *config.StaticCheckSettings) *scconfig.Config {
7979 HTTPStatusCodeWhitelist : settings .HTTPStatusCodeWhitelist ,
8080 }
8181
82- if len ( cfg .Checks ) == 0 {
82+ if cfg .Checks == nil {
8383 cfg .Checks = defaultChecks
8484 }
8585
86- if len ( cfg .Initialisms ) == 0 {
86+ if cfg .Initialisms == nil {
8787 cfg .Initialisms = append (cfg .Initialisms , scconfig .DefaultConfig .Initialisms ... )
8888 }
8989
90- if len ( cfg .DotImportWhitelist ) == 0 {
90+ if cfg .DotImportWhitelist == nil {
9191 cfg .DotImportWhitelist = append (cfg .DotImportWhitelist , scconfig .DefaultConfig .DotImportWhitelist ... )
9292 }
9393
94- if len ( cfg .HTTPStatusCodeWhitelist ) == 0 {
94+ if cfg .HTTPStatusCodeWhitelist == nil {
9595 cfg .HTTPStatusCodeWhitelist = append (cfg .HTTPStatusCodeWhitelist , scconfig .DefaultConfig .HTTPStatusCodeWhitelist ... )
9696 }
9797
Original file line number Diff line number Diff line change 1+ //golangcitest:args -Estaticcheck
2+ //golangcitest:config_path testdata/stylecheck_empty.yml
3+ package testdata
4+
5+ import "net/http"
6+
7+ func _ () {
8+ http .StatusText (200 ) // want "ST1013: should use constant http.StatusOK instead of numeric literal 200"
9+ http .StatusText (400 ) // want "ST1013: should use constant http.StatusBadRequest instead of numeric literal 400"
10+ http .StatusText (404 ) // want "ST1013: should use constant http.StatusNotFound instead of numeric literal 404"
11+ http .StatusText (418 ) // want "ST1013: should use constant http.StatusTeapot instead of numeric literal 418"
12+ http .StatusText (500 ) // want "ST1013: should use constant http.StatusInternalServerError instead of numeric literal 500"
13+ http .StatusText (503 ) // want "ST1013: should use constant http.StatusServiceUnavailable instead of numeric literal 503"
14+ http .StatusText (600 )
15+ }
Original file line number Diff line number Diff line change 1+ version : " 2"
2+
3+ linters :
4+ settings :
5+ staticcheck :
6+ checks : ["ST1013"]
7+ http-status-code-whitelist : [ ]
Original file line number Diff line number Diff line change 1+ //golangcitest:args -Estaticcheck
2+ //golangcitest:config_path testdata/stylecheck_nil.yml
3+ package testdata
4+
5+ import "net/http"
6+
7+ func _ () {
8+ http .StatusText (200 )
9+ http .StatusText (400 )
10+ http .StatusText (404 )
11+ http .StatusText (418 ) // want "ST1013: should use constant http.StatusTeapot instead of numeric literal 418"
12+ http .StatusText (500 )
13+ http .StatusText (503 ) // want "ST1013: should use constant http.StatusServiceUnavailable instead of numeric literal 503"
14+ http .StatusText (600 )
15+ }
Original file line number Diff line number Diff line change 1+ version : " 2"
2+
3+ linters :
4+ settings :
5+ staticcheck :
6+ checks : ["ST1013"]
You can’t perform that action at this time.
0 commit comments