Skip to content

Commit 519820a

Browse files
committed
chore: clean configuration v2
1 parent e24f69c commit 519820a

File tree

5 files changed

+85
-70
lines changed

5 files changed

+85
-70
lines changed

pkg/config/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ func NewDefault() *Config {
8787
}
8888
}
8989

90-
type Version struct {
91-
Format string `mapstructure:"format"`
92-
Debug bool `mapstructure:"debug"`
93-
}
94-
9590
func IsGoGreaterThanOrEqual(current, limit string) bool {
9691
v1, err := hcversion.NewVersion(strings.TrimPrefix(current, "go"))
9792
if err != nil {

pkg/config/formatters_settings.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ var defaultFormatterSettings = FormatterSettings{
55
Simplify: true,
66
},
77
Gci: GciSettings{
8-
Sections: []string{"standard", "default"},
9-
SkipGenerated: true,
8+
Sections: []string{"standard", "default"},
109
},
1110
GoLines: GoLinesSettings{
1211
MaxLen: 100,
@@ -28,7 +27,6 @@ type GciSettings struct {
2827
Sections []string `mapstructure:"sections"`
2928
NoInlineComments bool `mapstructure:"no-inline-comments"`
3029
NoPrefixComments bool `mapstructure:"no-prefix-comments"`
31-
SkipGenerated bool `mapstructure:"skip-generated"`
3230
CustomOrder bool `mapstructure:"custom-order"`
3331
NoLexOrder bool `mapstructure:"no-lex-order"`
3432
}

pkg/config/linters_settings.go

Lines changed: 82 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ type LintersSettings struct {
200200
Asasalint AsasalintSettings `mapstructure:"asasalint"`
201201
BiDiChk BiDiChkSettings `mapstructure:"bidichk"`
202202
CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"`
203-
Cyclop Cyclop `mapstructure:"cyclop"`
203+
Cyclop CyclopSettings `mapstructure:"cyclop"`
204204
Decorder DecorderSettings `mapstructure:"decorder"`
205205
Depguard DepGuardSettings `mapstructure:"depguard"`
206206
Dogsled DogsledSettings `mapstructure:"dogsled"`
@@ -314,7 +314,7 @@ type CopyLoopVarSettings struct {
314314
CheckAlias bool `mapstructure:"check-alias"`
315315
}
316316

317-
type Cyclop struct {
317+
type CyclopSettings struct {
318318
MaxComplexity int `mapstructure:"max-complexity"`
319319
PackageAverage float64 `mapstructure:"package-average"`
320320
}
@@ -505,21 +505,29 @@ type GoModDirectivesSettings struct {
505505
}
506506

507507
type GoModGuardSettings struct {
508-
Allowed struct {
509-
Modules []string `mapstructure:"modules"`
510-
Domains []string `mapstructure:"domains"`
511-
} `mapstructure:"allowed"`
512-
Blocked struct {
513-
Modules []map[string]struct {
514-
Recommendations []string `mapstructure:"recommendations"`
515-
Reason string `mapstructure:"reason"`
516-
} `mapstructure:"modules"`
517-
Versions []map[string]struct {
518-
Version string `mapstructure:"version"`
519-
Reason string `mapstructure:"reason"`
520-
} `mapstructure:"versions"`
521-
LocalReplaceDirectives bool `mapstructure:"local-replace-directives"`
522-
} `mapstructure:"blocked"`
508+
Allowed GoModGuardAllowed `mapstructure:"allowed"`
509+
Blocked GoModGuardBlocked `mapstructure:"blocked"`
510+
}
511+
512+
type GoModGuardAllowed struct {
513+
Modules []string `mapstructure:"modules"`
514+
Domains []string `mapstructure:"domains"`
515+
}
516+
517+
type GoModGuardBlocked struct {
518+
Modules []map[string]GoModGuardModule `mapstructure:"modules"`
519+
Versions []map[string]GoModGuardVersion `mapstructure:"versions"`
520+
LocalReplaceDirectives bool `mapstructure:"local-replace-directives"`
521+
}
522+
523+
type GoModGuardModule struct {
524+
Recommendations []string `mapstructure:"recommendations"`
525+
Reason string `mapstructure:"reason"`
526+
}
527+
528+
type GoModGuardVersion struct {
529+
Version string `mapstructure:"version"`
530+
Reason string `mapstructure:"reason"`
523531
}
524532

525533
type GoSecSettings struct {
@@ -545,7 +553,7 @@ type GovetSettings struct {
545553
EnableAll bool `mapstructure:"enable-all"`
546554
DisableAll bool `mapstructure:"disable-all"`
547555

548-
Settings map[string]map[string]any
556+
Settings map[string]map[string]any `mapstructure:"settings"`
549557
}
550558

551559
func (cfg *GovetSettings) Validate() error {
@@ -638,11 +646,13 @@ type MisspellExtraWords struct {
638646
}
639647

640648
type MustTagSettings struct {
641-
Functions []struct {
642-
Name string `mapstructure:"name"`
643-
Tag string `mapstructure:"tag"`
644-
ArgPos int `mapstructure:"arg-pos"`
645-
} `mapstructure:"functions"`
649+
Functions []MustTagFunction `mapstructure:"functions"`
650+
}
651+
652+
type MustTagFunction struct {
653+
Name string `mapstructure:"name"`
654+
Tag string `mapstructure:"tag"`
655+
ArgPos int `mapstructure:"arg-pos"`
646656
}
647657

648658
type NakedretSettings struct {
@@ -703,7 +713,7 @@ type PerfSprintSettings struct {
703713
}
704714

705715
type PreallocSettings struct {
706-
Simple bool
716+
Simple bool `mapstructure:"simple"`
707717
RangeLoops bool `mapstructure:"range-loops"`
708718
ForLoops bool `mapstructure:"for-loops"`
709719
}
@@ -735,24 +745,28 @@ type RecvcheckSettings struct {
735745
}
736746

737747
type ReviveSettings struct {
738-
Go string `mapstructure:"-"`
739-
MaxOpenFiles int `mapstructure:"max-open-files"`
740-
Confidence float64 `mapstructure:"confidence"`
741-
Severity string `mapstructure:"severity"`
742-
EnableAllRules bool `mapstructure:"enable-all-rules"`
743-
Rules []struct {
744-
Name string `mapstructure:"name"`
745-
Arguments []any `mapstructure:"arguments"`
746-
Severity string `mapstructure:"severity"`
747-
Disabled bool `mapstructure:"disabled"`
748-
Exclude []string `mapstructure:"exclude"`
749-
} `mapstructure:"rules"`
750-
ErrorCode int `mapstructure:"error-code"`
751-
WarningCode int `mapstructure:"warning-code"`
752-
Directives []struct {
753-
Name string `mapstructure:"name"`
754-
Severity string `mapstructure:"severity"`
755-
} `mapstructure:"directives"`
748+
Go string `mapstructure:"-"`
749+
MaxOpenFiles int `mapstructure:"max-open-files"`
750+
Confidence float64 `mapstructure:"confidence"`
751+
Severity string `mapstructure:"severity"`
752+
EnableAllRules bool `mapstructure:"enable-all-rules"`
753+
Rules []ReviveRule `mapstructure:"rules"`
754+
ErrorCode int `mapstructure:"error-code"`
755+
WarningCode int `mapstructure:"warning-code"`
756+
Directives []ReviveDirective `mapstructure:"directives"`
757+
}
758+
759+
type ReviveRule struct {
760+
Name string `mapstructure:"name"`
761+
Arguments []any `mapstructure:"arguments"`
762+
Severity string `mapstructure:"severity"`
763+
Disabled bool `mapstructure:"disabled"`
764+
Exclude []string `mapstructure:"exclude"`
765+
}
766+
767+
type ReviveDirective struct {
768+
Name string `mapstructure:"name"`
769+
Severity string `mapstructure:"severity"`
756770
}
757771

758772
type RowsErrCheckSettings struct {
@@ -830,30 +844,37 @@ type TestifylintSettings struct {
830844
EnabledCheckers []string `mapstructure:"enable"`
831845
DisabledCheckers []string `mapstructure:"disable"`
832846

833-
BoolCompare struct {
834-
IgnoreCustomTypes bool `mapstructure:"ignore-custom-types"`
835-
} `mapstructure:"bool-compare"`
847+
BoolCompare TestifylintBoolCompare `mapstructure:"bool-compare"`
848+
ExpectedActual TestifylintExpectedActual `mapstructure:"expected-actual"`
849+
Formatter TestifylintFormatter `mapstructure:"formatter"`
850+
GoRequire TestifylintGoRequire `mapstructure:"go-require"`
851+
RequireError TestifylintRequireError `mapstructure:"require-error"`
852+
SuiteExtraAssertCall TestifylintSuiteExtraAssertCall `mapstructure:"suite-extra-assert-call"`
853+
}
836854

837-
ExpectedActual struct {
838-
ExpVarPattern string `mapstructure:"pattern"`
839-
} `mapstructure:"expected-actual"`
855+
type TestifylintBoolCompare struct {
856+
IgnoreCustomTypes bool `mapstructure:"ignore-custom-types"`
857+
}
840858

841-
Formatter struct {
842-
CheckFormatString *bool `mapstructure:"check-format-string"`
843-
RequireFFuncs bool `mapstructure:"require-f-funcs"`
844-
} `mapstructure:"formatter"`
859+
type TestifylintExpectedActual struct {
860+
ExpVarPattern string `mapstructure:"pattern"`
861+
}
845862

846-
GoRequire struct {
847-
IgnoreHTTPHandlers bool `mapstructure:"ignore-http-handlers"`
848-
} `mapstructure:"go-require"`
863+
type TestifylintFormatter struct {
864+
CheckFormatString *bool `mapstructure:"check-format-string"`
865+
RequireFFuncs bool `mapstructure:"require-f-funcs"`
866+
}
849867

850-
RequireError struct {
851-
FnPattern string `mapstructure:"fn-pattern"`
852-
} `mapstructure:"require-error"`
868+
type TestifylintGoRequire struct {
869+
IgnoreHTTPHandlers bool `mapstructure:"ignore-http-handlers"`
870+
}
871+
872+
type TestifylintRequireError struct {
873+
FnPattern string `mapstructure:"fn-pattern"`
874+
}
853875

854-
SuiteExtraAssertCall struct {
855-
Mode string `mapstructure:"mode"`
856-
} `mapstructure:"suite-extra-assert-call"`
876+
type TestifylintSuiteExtraAssertCall struct {
877+
Mode string `mapstructure:"mode"`
857878
}
858879

859880
type TestpackageSettings struct {

pkg/goformatters/gci/internal/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/daixiang0/gci/pkg/config"
1010
"github.com/daixiang0/gci/pkg/section"
11+
1112
sectioni "github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/section"
1213
)
1314

pkg/golinters/cyclop/cyclop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/golangci/golangci-lint/pkg/goanalysis"
99
)
1010

11-
func New(settings *config.Cyclop) *goanalysis.Linter {
11+
func New(settings *config.CyclopSettings) *goanalysis.Linter {
1212
a := analyzer.NewAnalyzer()
1313

1414
var cfg map[string]map[string]any

0 commit comments

Comments
 (0)