From f9613275ab8d6b3200bb13b299e27843b116dc41 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 21 Apr 2025 13:30:17 +0200 Subject: [PATCH 1/4] fix: convert uint as pointer of uint --- pkg/commands/internal/migrate/cloner/cloner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/commands/internal/migrate/cloner/cloner.go b/pkg/commands/internal/migrate/cloner/cloner.go index 9c2400bc69b1..9a94aaf8e070 100644 --- a/pkg/commands/internal/migrate/cloner/cloner.go +++ b/pkg/commands/internal/migrate/cloner/cloner.go @@ -142,7 +142,7 @@ func convertType(expr ast.Expr) ast.Expr { } switch ident.Name { - case "bool", "string", "int", "int8", "int16", "int32", "int64", "float32", "float64": + case "bool", "string", "uint", "uint8", "uint16", "uint32", "uint64", "int", "int8", "int16", "int32", "int64", "float32", "float64": return &ast.StarExpr{X: ident} default: From ba73ed0d2226df49ec27f667723c9b10d4d36505 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 21 Apr 2025 13:30:36 +0200 Subject: [PATCH 2/4] chore: generate --- .../internal/migrate/versiontwo/formatters.go | 5 +-- .../migrate/versiontwo/linters_settings.go | 32 +++++++++++++------ .../internal/migrate/versiontwo/output.go | 3 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/pkg/commands/internal/migrate/versiontwo/formatters.go b/pkg/commands/internal/migrate/versiontwo/formatters.go index bd1b6f931155..417714947a69 100644 --- a/pkg/commands/internal/migrate/versiontwo/formatters.go +++ b/pkg/commands/internal/migrate/versiontwo/formatters.go @@ -9,6 +9,7 @@ type Formatters struct { } type FormatterExclusions struct { - Generated *string `yaml:"generated,omitempty" toml:"generated,multiline,omitempty"` - Paths []string `yaml:"paths,omitempty" toml:"paths,multiline,omitempty"` + Generated *string `yaml:"generated,omitempty" toml:"generated,multiline,omitempty"` + Paths []string `yaml:"paths,omitempty" toml:"paths,multiline,omitempty"` + WarnUnused *bool `yaml:"warn-unused,omitempty" toml:"warn-unused,multiline,omitempty"` } diff --git a/pkg/commands/internal/migrate/versiontwo/linters_settings.go b/pkg/commands/internal/migrate/versiontwo/linters_settings.go index 3461620e20f7..3a0d6b7b6a2a 100644 --- a/pkg/commands/internal/migrate/versiontwo/linters_settings.go +++ b/pkg/commands/internal/migrate/versiontwo/linters_settings.go @@ -21,6 +21,7 @@ type LintersSettings struct { Exhaustruct ExhaustructSettings `yaml:"exhaustruct,omitempty" toml:"exhaustruct,multiline,omitempty"` Fatcontext FatcontextSettings `yaml:"fatcontext,omitempty" toml:"fatcontext,multiline,omitempty"` Forbidigo ForbidigoSettings `yaml:"forbidigo,omitempty" toml:"forbidigo,multiline,omitempty"` + FuncOrder FuncOrderSettings `yaml:"funcorder,omitempty" toml:"funcorder,multiline,omitempty"` Funlen FunlenSettings `yaml:"funlen,omitempty" toml:"funlen,multiline,omitempty"` GinkgoLinter GinkgoLinterSettings `yaml:"ginkgolinter,omitempty" toml:"ginkgolinter,multiline,omitempty"` Gocognit GocognitSettings `yaml:"gocognit,omitempty" toml:"gocognit,multiline,omitempty"` @@ -210,6 +211,11 @@ type ForbidigoPattern struct { Msg *string `yaml:"msg,omitempty,omitempty" toml:"msg,omitempty,multiline,omitempty"` } +type FuncOrderSettings struct { + Constructor *bool `yaml:"constructor,omitempty,omitempty" toml:"constructor,omitempty,multiline,omitempty"` + StructMethod *bool `yaml:"struct-method,omitempty,omitempty" toml:"struct-method,omitempty,multiline,omitempty"` +} + type FunlenSettings struct { Lines *int `yaml:"lines,omitempty" toml:"lines,multiline,omitempty"` Statements *int `yaml:"statements,omitempty" toml:"statements,multiline,omitempty"` @@ -241,14 +247,18 @@ type GocognitSettings struct { } type GoConstSettings struct { - IgnoreStrings *string `yaml:"ignore-strings,omitempty" toml:"ignore-strings,multiline,omitempty"` - MatchWithConstants *bool `yaml:"match-constant,omitempty" toml:"match-constant,multiline,omitempty"` - MinStringLen *int `yaml:"min-len,omitempty" toml:"min-len,multiline,omitempty"` - MinOccurrencesCount *int `yaml:"min-occurrences,omitempty" toml:"min-occurrences,multiline,omitempty"` - ParseNumbers *bool `yaml:"numbers,omitempty" toml:"numbers,multiline,omitempty"` - NumberMin *int `yaml:"min,omitempty" toml:"min,multiline,omitempty"` - NumberMax *int `yaml:"max,omitempty" toml:"max,multiline,omitempty"` - IgnoreCalls *bool `yaml:"ignore-calls,omitempty" toml:"ignore-calls,multiline,omitempty"` + IgnoreStringValues []string `yaml:"ignore-string-values,omitempty" toml:"ignore-string-values,multiline,omitempty"` + MatchWithConstants *bool `yaml:"match-constant,omitempty" toml:"match-constant,multiline,omitempty"` + MinStringLen *int `yaml:"min-len,omitempty" toml:"min-len,multiline,omitempty"` + MinOccurrencesCount *int `yaml:"min-occurrences,omitempty" toml:"min-occurrences,multiline,omitempty"` + ParseNumbers *bool `yaml:"numbers,omitempty" toml:"numbers,multiline,omitempty"` + NumberMin *int `yaml:"min,omitempty" toml:"min,multiline,omitempty"` + NumberMax *int `yaml:"max,omitempty" toml:"max,multiline,omitempty"` + IgnoreCalls *bool `yaml:"ignore-calls,omitempty" toml:"ignore-calls,multiline,omitempty"` + FindDuplicates *bool `yaml:"find-duplicates,omitempty" toml:"find-duplicates,multiline,omitempty"` + EvalConstExpressions *bool `yaml:"eval-const-expressions,omitempty" toml:"eval-const-expressions,multiline,omitempty"` + + IgnoreStrings *string `yaml:"ignore-strings,omitempty" toml:"ignore-strings,multiline,omitempty"` } type GoCriticSettings struct { @@ -436,7 +446,7 @@ type MustTagFunction struct { } type NakedretSettings struct { - MaxFuncLines uint `yaml:"max-func-lines,omitempty" toml:"max-func-lines,multiline,omitempty"` + MaxFuncLines *uint `yaml:"max-func-lines,omitempty" toml:"max-func-lines,multiline,omitempty"` } type NestifSettings struct { @@ -444,6 +454,7 @@ type NestifSettings struct { } type NilNilSettings struct { + OnlyTwo *bool `yaml:"only-two,omitempty" toml:"only-two,multiline,omitempty"` DetectOpposite *bool `yaml:"detect-opposite,omitempty" toml:"detect-opposite,multiline,omitempty"` CheckedTypes []string `yaml:"checked-types,omitempty" toml:"checked-types,multiline,omitempty"` } @@ -560,6 +571,7 @@ type SlogLintSettings struct { NoGlobal *string `yaml:"no-global,omitempty" toml:"no-global,multiline,omitempty"` Context *string `yaml:"context,omitempty" toml:"context,multiline,omitempty"` StaticMsg *bool `yaml:"static-msg,omitempty" toml:"static-msg,multiline,omitempty"` + MsgStyle *string `yaml:"msg-style,omitempty" toml:"msg-style,multiline,omitempty"` NoRawKeys *bool `yaml:"no-raw-keys,omitempty" toml:"no-raw-keys,multiline,omitempty"` KeyNamingCase *string `yaml:"key-naming-case,omitempty" toml:"key-naming-case,multiline,omitempty"` ForbiddenKeys []string `yaml:"forbidden-keys,omitempty" toml:"forbidden-keys,multiline,omitempty"` @@ -639,6 +651,7 @@ type TestifylintExpectedActual struct { type TestifylintFormatter struct { CheckFormatString *bool `yaml:"check-format-string,omitempty" toml:"check-format-string,multiline,omitempty"` RequireFFuncs *bool `yaml:"require-f-funcs,omitempty" toml:"require-f-funcs,multiline,omitempty"` + RequireStringMsg *bool `yaml:"require-string-msg,omitempty" toml:"require-string-msg,multiline,omitempty"` } type TestifylintGoRequire struct { @@ -736,6 +749,7 @@ type WrapcheckSettings struct { IgnoreSigRegexps []string `yaml:"ignore-sig-regexps,omitempty" toml:"ignore-sig-regexps,multiline,omitempty"` IgnorePackageGlobs []string `yaml:"ignore-package-globs,omitempty" toml:"ignore-package-globs,multiline,omitempty"` IgnoreInterfaceRegexps []string `yaml:"ignore-interface-regexps,omitempty" toml:"ignore-interface-regexps,multiline,omitempty"` + ReportInternalErrors *bool `yaml:"report-internal-errors,omitempty" toml:"report-internal-errors,multiline,omitempty"` } type WSLSettings struct { diff --git a/pkg/commands/internal/migrate/versiontwo/output.go b/pkg/commands/internal/migrate/versiontwo/output.go index ed6bab7e375d..16afb6701eef 100644 --- a/pkg/commands/internal/migrate/versiontwo/output.go +++ b/pkg/commands/internal/migrate/versiontwo/output.go @@ -5,6 +5,7 @@ package versiontwo type Output struct { Formats Formats `yaml:"formats,omitempty" toml:"formats,multiline,omitempty"` SortOrder []string `yaml:"sort-order,omitempty" toml:"sort-order,multiline,omitempty"` - PathPrefix *string `yaml:"path-prefix,omitempty" toml:"path-prefix,multiline,omitempty"` ShowStats *bool `yaml:"show-stats,omitempty" toml:"show-stats,multiline,omitempty"` + PathPrefix *string `yaml:"path-prefix,omitempty" toml:"path-prefix,multiline,omitempty"` + PathMode *string `yaml:"path-mode,omitempty" toml:"path-mode,multiline,omitempty"` } From 4b907b96e703f37243c77c5999e5c75e5271478d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 21 Apr 2025 13:31:24 +0200 Subject: [PATCH 3/4] chore: use pointer of uint inside v1 structures --- pkg/commands/internal/migrate/versionone/linters_settings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/commands/internal/migrate/versionone/linters_settings.go b/pkg/commands/internal/migrate/versionone/linters_settings.go index 49427c447530..44583b7d34e0 100644 --- a/pkg/commands/internal/migrate/versionone/linters_settings.go +++ b/pkg/commands/internal/migrate/versionone/linters_settings.go @@ -489,7 +489,7 @@ type MustTagSettings struct { } type NakedretSettings struct { - MaxFuncLines uint `mapstructure:"max-func-lines"` + MaxFuncLines *uint `mapstructure:"max-func-lines"` } type NestifSettings struct { From b4e634d4c4123a32d64b1c58e9d464d57bc6ebca Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 21 Apr 2025 13:31:52 +0200 Subject: [PATCH 4/4] tests: add test case --- .../yaml/linters-settings_nakedret_zero.golden.yml | 6 ++++++ .../testdata/yaml/linters-settings_nakedret_zero.yml | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.golden.yml create mode 100644 pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.yml diff --git a/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.golden.yml b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.golden.yml new file mode 100644 index 000000000000..69e5a3b11394 --- /dev/null +++ b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.golden.yml @@ -0,0 +1,6 @@ +version: "2" + +linters: + settings: + nakedret: + max-func-lines: 0 diff --git a/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.yml b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.yml new file mode 100644 index 000000000000..c15f3c7bab1a --- /dev/null +++ b/pkg/commands/internal/migrate/testdata/yaml/linters-settings_nakedret_zero.yml @@ -0,0 +1,11 @@ +issues: + # Only to not generate unrelated elements inside golden. + exclude-use-default: false + # Only to not generate unrelated elements inside golden. + exclude-generated: strict + # Only to not generate unrelated elements inside golden. + exclude-dirs-use-default: false + +linters-settings: + nakedret: + max-func-lines: 0