5
5
"errors"
6
6
"runtime"
7
7
8
- "gopkg.in/yaml.v2 "
8
+ "gopkg.in/yaml.v3 "
9
9
)
10
10
11
11
var defaultLintersSettings = LintersSettings {
@@ -338,17 +338,16 @@ type ForbidigoSettings struct {
338
338
AnalyzeTypes bool `mapstructure:"analyze-types"`
339
339
}
340
340
341
- // ForbidigoPattern corresponds to forbidigo.pattern and adds
342
- // mapstructure support. The YAML field names must match what
343
- // forbidigo expects.
341
+ var _ encoding.TextUnmarshaler = & ForbidigoPattern {}
342
+
343
+ // ForbidigoPattern corresponds to forbidigo.pattern and adds mapstructure support.
344
+ // The YAML field names must match what forbidigo expects.
344
345
type ForbidigoPattern struct {
345
- // patternString gets populated when the config contains a string as
346
- // entry in ForbidigoSettings.Forbid[] because ForbidigoPattern
347
- // implements encoding.TextUnmarshaler and the reader uses the
348
- // mapstructure.TextUnmarshallerHookFunc as decoder hook.
346
+ // patternString gets populated when the config contains a string as entry in ForbidigoSettings.Forbid[]
347
+ // because ForbidigoPattern implements encoding.TextUnmarshaler
348
+ // and the reader uses the mapstructure.TextUnmarshallerHookFunc as decoder hook.
349
349
//
350
- // If the entry is a map, then the other fields are set as usual
351
- // by mapstructure.
350
+ // If the entry is a map, then the other fields are set as usual by mapstructure.
352
351
patternString string
353
352
354
353
Pattern string `yaml:"p" mapstructure:"p"`
@@ -362,21 +361,19 @@ func (p *ForbidigoPattern) UnmarshalText(text []byte) error {
362
361
return nil
363
362
}
364
363
365
- // MarshalString converts the pattern into a string as needed by
366
- // forbidigo.NewLinter.
364
+ // MarshalString converts the pattern into a string as needed by forbidigo.NewLinter.
367
365
//
368
- // MarshalString is intentionally not called MarshalText although it has the
369
- // same signature because implementing encoding.TextMarshaler led to infinite
370
- // recursion when yaml.Marshal called MarshalText.
366
+ // MarshalString is intentionally not called MarshalText,
367
+ // although it has the same signature
368
+ // because implementing encoding.TextMarshaler led to infinite recursion when yaml.Marshal called MarshalText.
371
369
func (p * ForbidigoPattern ) MarshalString () ([]byte , error ) {
372
370
if p .patternString != "" {
373
371
return []byte (p .patternString ), nil
374
372
}
373
+
375
374
return yaml .Marshal (p )
376
375
}
377
376
378
- var _ encoding.TextUnmarshaler = & ForbidigoPattern {}
379
-
380
377
type FunlenSettings struct {
381
378
Lines int
382
379
Statements int
0 commit comments