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 {
838
838
}
839
839
840
840
func (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
842
842
}
843
843
844
844
type TagAlignSettings struct {
Original file line number Diff line number Diff line change @@ -79,19 +79,19 @@ func createConfig(settings *config.StaticCheckSettings) *scconfig.Config {
79
79
HTTPStatusCodeWhitelist : settings .HTTPStatusCodeWhitelist ,
80
80
}
81
81
82
- if len ( cfg .Checks ) == 0 {
82
+ if cfg .Checks == nil {
83
83
cfg .Checks = defaultChecks
84
84
}
85
85
86
- if len ( cfg .Initialisms ) == 0 {
86
+ if cfg .Initialisms == nil {
87
87
cfg .Initialisms = append (cfg .Initialisms , scconfig .DefaultConfig .Initialisms ... )
88
88
}
89
89
90
- if len ( cfg .DotImportWhitelist ) == 0 {
90
+ if cfg .DotImportWhitelist == nil {
91
91
cfg .DotImportWhitelist = append (cfg .DotImportWhitelist , scconfig .DefaultConfig .DotImportWhitelist ... )
92
92
}
93
93
94
- if len ( cfg .HTTPStatusCodeWhitelist ) == 0 {
94
+ if cfg .HTTPStatusCodeWhitelist == nil {
95
95
cfg .HTTPStatusCodeWhitelist = append (cfg .HTTPStatusCodeWhitelist , scconfig .DefaultConfig .HTTPStatusCodeWhitelist ... )
96
96
}
97
97
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