Skip to content

dev: gofmt -w -r 'interface{} -> any' pkg scripts #3742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ type GoCriticSettings struct {
SettingsPerCheck map[string]GoCriticCheckSettings `mapstructure:"settings"`
}

type GoCriticCheckSettings map[string]interface{}
type GoCriticCheckSettings map[string]any

type GoCycloSettings struct {
MinComplexity int `mapstructure:"min-complexity"`
Expand Down Expand Up @@ -421,11 +421,11 @@ type GoLintSettings struct {
}

type GoMndSettings struct {
Settings map[string]map[string]interface{} // Deprecated
Checks []string `mapstructure:"checks"`
IgnoredNumbers []string `mapstructure:"ignored-numbers"`
IgnoredFiles []string `mapstructure:"ignored-files"`
IgnoredFunctions []string `mapstructure:"ignored-functions"`
Settings map[string]map[string]any // Deprecated
Checks []string `mapstructure:"checks"`
IgnoredNumbers []string `mapstructure:"ignored-numbers"`
IgnoredFiles []string `mapstructure:"ignored-files"`
IgnoredFunctions []string `mapstructure:"ignored-functions"`
}

type GoModDirectivesSettings struct {
Expand Down Expand Up @@ -454,13 +454,13 @@ type GoModGuardSettings struct {
}

type GoSecSettings struct {
Includes []string `mapstructure:"includes"`
Excludes []string `mapstructure:"excludes"`
Severity string `mapstructure:"severity"`
Confidence string `mapstructure:"confidence"`
ExcludeGenerated bool `mapstructure:"exclude-generated"`
Config map[string]interface{} `mapstructure:"config"`
Concurrency int `mapstructure:"concurrency"`
Includes []string `mapstructure:"includes"`
Excludes []string `mapstructure:"excludes"`
Severity string `mapstructure:"severity"`
Confidence string `mapstructure:"confidence"`
ExcludeGenerated bool `mapstructure:"exclude-generated"`
Config map[string]any `mapstructure:"config"`
Concurrency int `mapstructure:"concurrency"`
}

type GosmopolitanSettings struct {
Expand All @@ -473,7 +473,7 @@ type GosmopolitanSettings struct {
type GovetSettings struct {
Go string `mapstructure:"-"`
CheckShadowing bool `mapstructure:"check-shadowing"`
Settings map[string]map[string]interface{}
Settings map[string]map[string]any

Enable []string
Disable []string
Expand Down Expand Up @@ -628,7 +628,7 @@ type ReviveSettings struct {
EnableAllRules bool `mapstructure:"enable-all-rules"`
Rules []struct {
Name string
Arguments []interface{}
Arguments []any
Severity string
Disabled bool
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/fsutils/filecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func PrettifyBytesCount(n int64) string {
func (fc *FileCache) PrintStats(log logutils.Log) {
var size int64
var mapLen int
fc.files.Range(func(_, fileBytes interface{}) bool {
fc.files.Range(func(_, fileBytes any) bool {
mapLen++
size += int64(len(fileBytes.([]byte)))

Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/bidichk.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func NewBiDiChkFuncName(cfg *config.BiDiChkSettings) *goanalysis.Linter {
a := bidichk.NewAnalyzer()

cfgMap := map[string]map[string]interface{}{}
cfgMap := map[string]map[string]any{}
if cfg != nil {
var opts []string

Expand Down Expand Up @@ -45,7 +45,7 @@ func NewBiDiChkFuncName(cfg *config.BiDiChkSettings) *goanalysis.Linter {
opts = append(opts, "POP-DIRECTIONAL-ISOLATE")
}

cfgMap[a.Name] = map[string]interface{}{
cfgMap[a.Name] = map[string]any{
"disallowed-runes": strings.Join(opts, ","),
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/golinters/cyclop.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const cyclopName = "cyclop"
func NewCyclop(settings *config.Cyclop) *goanalysis.Linter {
a := analyzer.NewAnalyzer()

var cfg map[string]map[string]interface{}
var cfg map[string]map[string]any
if settings != nil {
d := map[string]interface{}{
d := map[string]any{
"skipTests": settings.SkipTests,
}

Expand All @@ -27,7 +27,7 @@ func NewCyclop(settings *config.Cyclop) *goanalysis.Linter {
d["packageAverage"] = settings.PackageAverage
}

cfg = map[string]map[string]interface{}{a.Name: d}
cfg = map[string]map[string]any{a.Name: d}
}

return goanalysis.NewLinter(
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/deadcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewDeadcode() *goanalysis.Linter {
analyzer := &analysis.Analyzer{
Name: deadcodeName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (interface{}, error) {
Run: func(pass *analysis.Pass) (any, error) {
prog := goanalysis.MakeFakeLoaderProgram(pass)

issues, err := deadcodeAPI.Run(prog)
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/decorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func NewDecorder(settings *config.DecorderSettings) *goanalysis.Linter {
a := decorder.Analyzer

// disable all rules/checks by default
cfg := map[string]interface{}{
cfg := map[string]any{
"disable-dec-num-check": true,
"disable-dec-order-check": true,
"disable-init-func-first-check": true,
Expand All @@ -31,6 +31,6 @@ func NewDecorder(settings *config.DecorderSettings) *goanalysis.Linter {
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
map[string]map[string]interface{}{a.Name: cfg},
map[string]map[string]any{a.Name: cfg},
).WithLoadMode(goanalysis.LoadModeSyntax)
}
2 changes: 1 addition & 1 deletion pkg/golinters/depguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewDepguard(settings *config.DepGuardSettings) *goanalysis.Linter {
).WithContextSetter(func(lintCtx *linter.Context) {
dg, err := newDepGuard(settings)

analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
analyzer.Run = func(pass *analysis.Pass) (any, error) {
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/dogsled.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewDogsled(settings *config.DogsledSettings) *goanalysis.Linter {
analyzer := &analysis.Analyzer{
Name: dogsledName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (interface{}, error) {
Run: func(pass *analysis.Pass) (any, error) {
issues := runDogsled(pass, settings)

if len(issues) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/dupl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewDupl(settings *config.DuplSettings) *goanalysis.Linter {
analyzer := &analysis.Analyzer{
Name: duplName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (interface{}, error) {
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runDupl(pass, settings)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/dupword.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
func NewDupWord(setting *config.DupWordSettings) *goanalysis.Linter {
a := dupword.NewAnalyzer()

cfgMap := map[string]map[string]interface{}{}
cfgMap := map[string]map[string]any{}
if setting != nil {
cfgMap[a.Name] = map[string]interface{}{
cfgMap[a.Name] = map[string]any{
"keyword": strings.Join(setting.Keywords, ","),
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/errcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewErrcheck(settings *config.ErrcheckSettings) *goanalysis.Linter {

checker.Tags = lintCtx.Cfg.Run.BuildTags

analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
analyzer.Run = func(pass *analysis.Pass) (any, error) {
issues := runErrCheck(lintCtx, pass, checker)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions pkg/golinters/errchkjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
func NewErrChkJSONFuncName(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
a := errchkjson.NewAnalyzer()

cfgMap := map[string]map[string]interface{}{}
cfgMap[a.Name] = map[string]interface{}{
cfgMap := map[string]map[string]any{}
cfgMap[a.Name] = map[string]any{
"omit-safe": true,
}
if cfg != nil {
cfgMap[a.Name] = map[string]interface{}{
cfgMap[a.Name] = map[string]any{
"omit-safe": !cfg.CheckErrorFreeEncoding,
"report-no-exported": cfg.ReportNoExported,
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/errorlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter {
a := errorlint.NewAnalyzer()

cfgMap := map[string]map[string]interface{}{}
cfgMap := map[string]map[string]any{}

if cfg != nil {
cfgMap[a.Name] = map[string]interface{}{
cfgMap[a.Name] = map[string]any{
"errorf": cfg.Errorf,
"errorf-multi": cfg.ErrorfMulti,
"asserts": cfg.Asserts,
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/exhaustive.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter {
a := exhaustive.Analyzer

var cfg map[string]map[string]interface{}
var cfg map[string]map[string]any
if settings != nil {
cfg = map[string]map[string]interface{}{
cfg = map[string]map[string]any{
a.Name: {
exhaustive.CheckFlag: settings.Check,
exhaustive.CheckGeneratedFlag: settings.CheckGenerated,
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/exhaustivestruct.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
func NewExhaustiveStruct(settings *config.ExhaustiveStructSettings) *goanalysis.Linter {
a := analyzer.Analyzer

var cfg map[string]map[string]interface{}
var cfg map[string]map[string]any
if settings != nil {
cfg = map[string]map[string]interface{}{
cfg = map[string]map[string]any{
a.Name: {
"struct_patterns": strings.Join(settings.StructPatterns, ","),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/forbidigo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewForbidigo(settings *config.ForbidigoSettings) *goanalysis.Linter {
analyzer := &analysis.Analyzer{
Name: forbidigoName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (interface{}, error) {
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runForbidigo(pass, settings)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/funlen.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewFunlen(settings *config.FunlenSettings) *goanalysis.Linter {
analyzer := &analysis.Analyzer{
Name: funlenName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (interface{}, error) {
Run: func(pass *analysis.Pass) (any, error) {
issues := runFunlen(pass, settings)

if len(issues) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/gci.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
[]*analysis.Analyzer{analyzer},
nil,
).WithContextSetter(func(lintCtx *linter.Context) {
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
analyzer.Run = func(pass *analysis.Pass) (any, error) {
issues, err := runGci(pass, lintCtx, cfg, &lock)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/ginkgolinter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
func NewGinkgoLinter(cfg *config.GinkgoLinterSettings) *goanalysis.Linter {
a := ginkgolinter.NewAnalyzer()

cfgMap := make(map[string]map[string]interface{})
cfgMap := make(map[string]map[string]any)
if cfg != nil {
cfgMap[a.Name] = map[string]interface{}{
cfgMap[a.Name] = map[string]any{
"suppress-len-assertion": cfg.SuppressLenAssertion,
"suppress-nil-assertion": cfg.SuppressNilAssertion,
"suppress-err-assertion": cfg.SuppressErrAssertion,
Expand Down
12 changes: 6 additions & 6 deletions pkg/golinters/goanalysis/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ const (
type Linter struct {
name, desc string
analyzers []*analysis.Analyzer
cfg map[string]map[string]interface{}
cfg map[string]map[string]any
issuesReporter func(*linter.Context) []Issue
contextSetter func(*linter.Context)
loadMode LoadMode
needUseOriginalPackages bool
}

func NewLinter(name, desc string, analyzers []*analysis.Analyzer, cfg map[string]map[string]interface{}) *Linter {
func NewLinter(name, desc string, analyzers []*analysis.Analyzer, cfg map[string]map[string]any) *Linter {
return &Linter{name: name, desc: desc, analyzers: analyzers, cfg: cfg}
}

Expand Down Expand Up @@ -102,7 +102,7 @@ func (lnt *Linter) allAnalyzerNames() []string {
return ret
}

func (lnt *Linter) configureAnalyzer(a *analysis.Analyzer, cfg map[string]interface{}) error {
func (lnt *Linter) configureAnalyzer(a *analysis.Analyzer, cfg map[string]any) error {
for k, v := range cfg {
f := a.Flags.Lookup(k)
if f == nil {
Expand Down Expand Up @@ -195,12 +195,12 @@ func allFlagNames(fs *flag.FlagSet) []string {
return ret
}

func valueToString(v interface{}) string {
func valueToString(v any) string {
if ss, ok := v.([]string); ok {
return strings.Join(ss, ",")
}

if is, ok := v.([]interface{}); ok {
if is, ok := v.([]any); ok {
var ss []string
for _, i := range is {
ss = append(ss, fmt.Sprint(i))
Expand All @@ -212,6 +212,6 @@ func valueToString(v interface{}) string {
return fmt.Sprint(v)
}

func DummyRun(_ *analysis.Pass) (interface{}, error) {
func DummyRun(_ *analysis.Pass) (any, error) {
return nil, nil
}
4 changes: 2 additions & 2 deletions pkg/golinters/goanalysis/runner_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type action struct {
deps []*action
objectFacts map[objectFactKey]analysis.Fact
packageFacts map[packageFactKey]analysis.Fact
result interface{}
result any
diagnostics []analysis.Diagnostic
err error
r *runner
Expand Down Expand Up @@ -145,7 +145,7 @@ func (act *action) analyze() {

// Plumb the output values of the dependencies
// into the inputs of this action. Also facts.
inputs := make(map[*analysis.Analyzer]interface{})
inputs := make(map[*analysis.Analyzer]any)
startedAt := time.Now()
for _, dep := range act.deps {
if dep.pkg == act.pkg {
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/goanalysis/runner_loadingpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ type importerFunc func(path string) (*types.Package, error)

func (f importerFunc) Import(path string) (*types.Package, error) { return f(path) }

func sizeOfValueTreeBytes(v interface{}) int {
func sizeOfValueTreeBytes(v any) int {
return sizeOfReflectValueTreeBytes(reflect.ValueOf(v), map[uintptr]struct{}{})
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/gochecknoglobals.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func NewGochecknoglobals() *goanalysis.Linter {
// pass the `t` flag as true to the analyzer before running it. This can be
// turned off by using the regular golangci-lint flags such as `--tests` or
// `--skip-files`.
linterConfig := map[string]map[string]interface{}{
linterConfig := map[string]map[string]any{
gochecknoglobals.Name: {
"t": true,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/gochecknoinits.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewGochecknoinits() *goanalysis.Linter {
analyzer := &analysis.Analyzer{
Name: gochecknoinitsName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (interface{}, error) {
Run: func(pass *analysis.Pass) (any, error) {
var res []goanalysis.Issue
for _, file := range pass.Files {
fileIssues := checkFileForInits(file, pass.Fset)
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/gocognit.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewGocognit(settings *config.GocognitSettings) *goanalysis.Linter {
analyzer := &analysis.Analyzer{
Name: goanalysis.TheOnlyAnalyzerName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (interface{}, error) {
Run: func(pass *analysis.Pass) (any, error) {
issues := runGocognit(pass, settings)

if len(issues) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/goconst.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewGoconst(settings *config.GoConstSettings) *goanalysis.Linter {
analyzer := &analysis.Analyzer{
Name: goconstName,
Doc: goanalysis.TheOnlyanalyzerDoc,
Run: func(pass *analysis.Pass) (interface{}, error) {
Run: func(pass *analysis.Pass) (any, error) {
issues, err := runGoconst(pass, settings)
if err != nil {
return nil, err
Expand Down
Loading