Skip to content

Commit f507714

Browse files
committed
review: fix dependencies and cosmetic changes
1 parent 04b16cf commit f507714

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ require (
7171
github.com/mgechev/revive v1.3.2
7272
github.com/mitchellh/go-homedir v1.1.0
7373
github.com/mitchellh/go-ps v1.0.0
74+
github.com/mitchellh/mapstructure v1.5.0
7475
github.com/moricho/tparallel v0.3.1
7576
github.com/nakabonne/nestif v0.3.1
7677
github.com/nishanths/exhaustive v0.10.0
@@ -153,7 +154,6 @@ require (
153154
github.com/mattn/go-isatty v0.0.17 // indirect
154155
github.com/mattn/go-runewidth v0.0.9 // indirect
155156
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
156-
github.com/mitchellh/mapstructure v1.5.0
157157
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect
158158
github.com/olekukonko/tablewriter v0.0.5 // indirect
159159
github.com/pelletier/go-toml v1.9.5 // indirect
@@ -190,6 +190,6 @@ require (
190190
golang.org/x/text v0.9.0 // indirect
191191
google.golang.org/protobuf v1.28.0 // indirect
192192
gopkg.in/ini.v1 v1.67.0 // indirect
193-
gopkg.in/yaml.v2 v2.4.0
193+
gopkg.in/yaml.v2 v2.4.0 // indirect
194194
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
195195
)

pkg/config/linters_settings.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"errors"
66
"runtime"
77

8-
"gopkg.in/yaml.v2"
8+
"gopkg.in/yaml.v3"
99
)
1010

1111
var defaultLintersSettings = LintersSettings{
@@ -338,17 +338,16 @@ type ForbidigoSettings struct {
338338
AnalyzeTypes bool `mapstructure:"analyze-types"`
339339
}
340340

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.
344345
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.
349349
//
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.
352351
patternString string
353352

354353
Pattern string `yaml:"p" mapstructure:"p"`
@@ -362,21 +361,19 @@ func (p *ForbidigoPattern) UnmarshalText(text []byte) error {
362361
return nil
363362
}
364363

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.
367365
//
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.
371369
func (p *ForbidigoPattern) MarshalString() ([]byte, error) {
372370
if p.patternString != "" {
373371
return []byte(p.patternString), nil
374372
}
373+
375374
return yaml.Marshal(p)
376375
}
377376

378-
var _ encoding.TextUnmarshaler = &ForbidigoPattern{}
379-
380377
type FunlenSettings struct {
381378
Lines int
382379
Statements int

0 commit comments

Comments
 (0)