|
1 | 1 | package config
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "encoding" |
5 | 4 | "errors"
|
6 | 5 | "fmt"
|
7 | 6 | "runtime"
|
8 |
| - |
9 |
| - "gopkg.in/yaml.v3" |
10 | 7 | )
|
11 | 8 |
|
12 | 9 | var defaultLintersSettings = LintersSettings{
|
@@ -425,42 +422,12 @@ type ForbidigoSettings struct {
|
425 | 422 | AnalyzeTypes bool `mapstructure:"analyze-types"`
|
426 | 423 | }
|
427 | 424 |
|
428 |
| -var _ encoding.TextUnmarshaler = &ForbidigoPattern{} |
429 |
| - |
430 |
| -// ForbidigoPattern corresponds to forbidigo.pattern and adds mapstructure support. |
431 |
| -// The YAML field names must match what forbidigo expects. |
432 | 425 | type ForbidigoPattern struct {
|
433 |
| - // patternString gets populated when the config contains a string as entry in ForbidigoSettings.Forbid[] |
434 |
| - // because ForbidigoPattern implements encoding.TextUnmarshaler |
435 |
| - // and the reader uses the mapstructure.TextUnmarshallerHookFunc as decoder hook. |
436 |
| - // |
437 |
| - // If the entry is a map, then the other fields are set as usual by mapstructure. |
438 |
| - patternString string |
439 |
| - |
440 |
| - Pattern string `yaml:"p" mapstructure:"p"` |
| 426 | + Pattern string `yaml:"p" mapstructure:"pattern"` |
441 | 427 | Package string `yaml:"pkg,omitempty" mapstructure:"pkg,omitempty"`
|
442 | 428 | Msg string `yaml:"msg,omitempty" mapstructure:"msg,omitempty"`
|
443 | 429 | }
|
444 | 430 |
|
445 |
| -func (p *ForbidigoPattern) UnmarshalText(text []byte) error { |
446 |
| - // Validation happens when instantiating forbidigo. |
447 |
| - p.patternString = string(text) |
448 |
| - return nil |
449 |
| -} |
450 |
| - |
451 |
| -// MarshalString converts the pattern into a string as needed by forbidigo.NewLinter. |
452 |
| -// |
453 |
| -// MarshalString is intentionally not called MarshalText, |
454 |
| -// although it has the same signature |
455 |
| -// because implementing encoding.TextMarshaler led to infinite recursion when yaml.Marshal called MarshalText. |
456 |
| -func (p *ForbidigoPattern) MarshalString() ([]byte, error) { |
457 |
| - if p.patternString != "" { |
458 |
| - return []byte(p.patternString), nil |
459 |
| - } |
460 |
| - |
461 |
| - return yaml.Marshal(p) |
462 |
| -} |
463 |
| - |
464 | 431 | type FunlenSettings struct {
|
465 | 432 | Lines int `mapstructure:"lines"`
|
466 | 433 | Statements int `mapstructure:"statements"`
|
@@ -563,7 +530,7 @@ type GoModGuardSettings struct {
|
563 | 530 | Version string `mapstructure:"version"`
|
564 | 531 | Reason string `mapstructure:"reason"`
|
565 | 532 | } `mapstructure:"versions"`
|
566 |
| - LocalReplaceDirectives bool `mapstructure:"local_replace_directives"` |
| 533 | + LocalReplaceDirectives bool `mapstructure:"local-replace-directives"` |
567 | 534 | } `mapstructure:"blocked"`
|
568 | 535 | }
|
569 | 536 |
|
@@ -673,11 +640,10 @@ type MakezeroSettings struct {
|
673 | 640 | }
|
674 | 641 |
|
675 | 642 | type MisspellSettings struct {
|
676 |
| - Mode string `mapstructure:"mode"` |
677 |
| - Locale string `mapstructure:"locale"` |
678 |
| - ExtraWords []MisspellExtraWords `mapstructure:"extra-words"` |
679 |
| - // TODO(ldez): v2 the option must be renamed to `IgnoredRules`. |
680 |
| - IgnoreWords []string `mapstructure:"ignore-words"` |
| 643 | + Mode string `mapstructure:"mode"` |
| 644 | + Locale string `mapstructure:"locale"` |
| 645 | + ExtraWords []MisspellExtraWords `mapstructure:"extra-words"` |
| 646 | + IgnoreRules []string `mapstructure:"ignore-rules"` |
681 | 647 | }
|
682 | 648 |
|
683 | 649 | type MisspellExtraWords struct {
|
@@ -758,7 +724,7 @@ type PreallocSettings struct {
|
758 | 724 |
|
759 | 725 | type PredeclaredSettings struct {
|
760 | 726 | Ignore string `mapstructure:"ignore"`
|
761 |
| - Qualified bool `mapstructure:"q"` |
| 727 | + Qualified bool `mapstructure:"qualified-name"` |
762 | 728 | }
|
763 | 729 |
|
764 | 730 | type PromlinterSettings struct {
|
@@ -988,12 +954,11 @@ type WhitespaceSettings struct {
|
988 | 954 | }
|
989 | 955 |
|
990 | 956 | type WrapcheckSettings struct {
|
991 |
| - ExtraIgnoreSigs []string `mapstructure:"extra-ignore-sigs"` |
992 |
| - // TODO(ldez): v2 the options must be renamed to use hyphen. |
993 |
| - IgnoreSigs []string `mapstructure:"ignoreSigs"` |
994 |
| - IgnoreSigRegexps []string `mapstructure:"ignoreSigRegexps"` |
995 |
| - IgnorePackageGlobs []string `mapstructure:"ignorePackageGlobs"` |
996 |
| - IgnoreInterfaceRegexps []string `mapstructure:"ignoreInterfaceRegexps"` |
| 957 | + ExtraIgnoreSigs []string `mapstructure:"extra-ignore-sigs"` |
| 958 | + IgnoreSigs []string `mapstructure:"ignore-sigs"` |
| 959 | + IgnoreSigRegexps []string `mapstructure:"ignore-sig-regexps"` |
| 960 | + IgnorePackageGlobs []string `mapstructure:"ignore-package-globs"` |
| 961 | + IgnoreInterfaceRegexps []string `mapstructure:"ignore-interface-regexps"` |
997 | 962 | }
|
998 | 963 |
|
999 | 964 | type WSLSettings struct {
|
|
0 commit comments