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,8 +422,6 @@ type ForbidigoSettings struct {
425
422
AnalyzeTypes bool `mapstructure:"analyze-types"`
426
423
}
427
424
428
- var _ encoding.TextUnmarshaler = & ForbidigoPattern {}
429
-
430
425
// ForbidigoPattern corresponds to forbidigo.pattern and adds mapstructure support.
431
426
// The YAML field names must match what forbidigo expects.
432
427
type ForbidigoPattern struct {
@@ -437,30 +432,11 @@ type ForbidigoPattern struct {
437
432
// If the entry is a map, then the other fields are set as usual by mapstructure.
438
433
patternString string
439
434
440
- Pattern string `yaml:"p" mapstructure:"p "`
435
+ Pattern string `yaml:"p" mapstructure:"pattern "`
441
436
Package string `yaml:"pkg,omitempty" mapstructure:"pkg,omitempty"`
442
437
Msg string `yaml:"msg,omitempty" mapstructure:"msg,omitempty"`
443
438
}
444
439
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
440
type FunlenSettings struct {
465
441
Lines int `mapstructure:"lines"`
466
442
Statements int `mapstructure:"statements"`
0 commit comments