Skip to content

Commit 5f3fe1e

Browse files
committed
review
1 parent 4118d9d commit 5f3fe1e

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

pkg/commands/internal/migrate/migrate_linters_settings.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -789,20 +789,29 @@ func toSpancheckSettings(old versionone.SpancheckSettings) versiontwo.SpancheckS
789789
}
790790

791791
func toStaticCheckSettings(old versionone.LintersSettings) versiontwo.StaticCheckSettings {
792-
checks := slices.Compact(
793-
slices.SortedFunc(
794-
slices.Values(
795-
slices.Concat(old.Staticcheck.Checks, old.Stylecheck.Checks, old.Gosimple.Checks),
796-
),
797-
func(a, b string) int {
798-
if a == "*" || a == "all" {
799-
return 1
800-
}
801-
802-
return strings.Compare(a, b)
803-
},
804-
),
805-
)
792+
var checks []string
793+
794+
for _, check := range slices.Concat(old.Staticcheck.Checks, old.Stylecheck.Checks, old.Gosimple.Checks) {
795+
if check == "*" {
796+
checks = append(checks, "all")
797+
continue
798+
}
799+
checks = append(checks, check)
800+
}
801+
802+
checks = Unique(checks)
803+
804+
slices.SortFunc(checks, func(a, b string) int {
805+
if a == "all" {
806+
return -1
807+
}
808+
809+
if b == "all" {
810+
return 1
811+
}
812+
813+
return strings.Compare(a, b)
814+
})
806815

807816
return versiontwo.StaticCheckSettings{
808817
Checks: checks,

pkg/commands/internal/migrate/testdata/yaml/linters-settings_staticcheck_merge.golden.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ linters:
33
settings:
44
staticcheck:
55
checks:
6-
- '*'
6+
- all
77
- -S1000
88
- -S1001
99
- -S1002
@@ -152,7 +152,6 @@ linters:
152152
- ST1021
153153
- ST1022
154154
- ST1023
155-
- all
156155
initialisms:
157156
- ACL
158157
- API

0 commit comments

Comments
 (0)