Skip to content

Commit a05ea26

Browse files
authored
dev: simplify mnd implementation (#5731)
1 parent 3afce89 commit a05ea26

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

pkg/golinters/mnd/mnd.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import (
99
)
1010

1111
func New(settings *config.MndSettings) *goanalysis.Linter {
12-
return newMND(mnd.Analyzer, settings, nil)
13-
}
12+
a := mnd.Analyzer
1413

15-
func newMND(a *analysis.Analyzer, settings *config.MndSettings, linterCfg map[string]map[string]any) *goanalysis.Linter {
16-
if len(linterCfg) == 0 && settings != nil {
14+
var linterCfg map[string]map[string]any
15+
if settings != nil {
1716
cfg := make(map[string]any)
1817
if len(settings.Checks) > 0 {
1918
cfg["checks"] = settings.Checks
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//golangcitest:args -Emnd
2+
//golangcitest:config_path testdata/mnd_custom.yml
3+
package testdata
4+
5+
import (
6+
"log"
7+
"net/http"
8+
"time"
9+
)
10+
11+
func Mnd() {
12+
c := &http.Client{
13+
Timeout: 5 * time.Second,
14+
}
15+
16+
res, err := c.Get("https://www.google.com")
17+
if err != nil {
18+
log.Fatal(err)
19+
}
20+
defer res.Body.Close()
21+
if res.StatusCode != 200 { // want "Magic number: 200, in <condition> detected"
22+
log.Println("Something went wrong")
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
mnd:
6+
ignored-numbers:
7+
- '5'

0 commit comments

Comments
 (0)