forked from golangci/golangci-lint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmigrate_linters.go
31 lines (27 loc) · 955 Bytes
/
migrate_linters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package migrate
import (
"github.com/golangci/golangci-lint/v2/pkg/commands/internal/migrate/ptr"
"github.com/golangci/golangci-lint/v2/pkg/commands/internal/migrate/versionone"
"github.com/golangci/golangci-lint/v2/pkg/commands/internal/migrate/versiontwo"
)
func toLinters(old *versionone.Config) versiontwo.Linters {
enable, disable := ProcessEffectiveLinters(old.Linters)
return versiontwo.Linters{
Default: getDefaultName(old.Linters),
Enable: onlyLinterNames(convertStaticcheckLinterNames(enable)),
Disable: onlyLinterNames(convertDisabledStaticcheckLinterNames(disable)),
FastOnly: nil,
Settings: toLinterSettings(old.LintersSettings),
Exclusions: toExclusions(old),
}
}
func getDefaultName(old versionone.Linters) *string {
switch {
case ptr.Deref(old.DisableAll):
return ptr.Pointer("none")
case ptr.Deref(old.EnableAll):
return ptr.Pointer("all")
default:
return nil // standard is the default
}
}