Skip to content

Commit 23ec808

Browse files
committed
chore: handle output.format deprecation
1 parent e525497 commit 23ec808

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

pkg/config/loader.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ func (l *Loader) Load() error {
6161

6262
l.handleGoVersion()
6363

64-
l.handleDeprecation()
64+
err = l.handleDeprecation()
65+
if err != nil {
66+
return err
67+
}
6568

6669
err = l.handleEnableOnlyOption()
6770
if err != nil {
@@ -279,7 +282,7 @@ func (l *Loader) handleGoVersion() {
279282
}
280283
}
281284

282-
func (l *Loader) handleDeprecation() {
285+
func (l *Loader) handleDeprecation() error {
283286
if len(l.cfg.Run.SkipFiles) > 0 {
284287
l.warn("The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`.")
285288
l.cfg.Issues.ExcludeFiles = l.cfg.Run.SkipFiles
@@ -301,6 +304,20 @@ func (l *Loader) handleDeprecation() {
301304
l.warn("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`")
302305
}
303306
l.cfg.Output.ShowStats = l.cfg.Run.ShowStats || l.cfg.Output.ShowStats
307+
308+
if l.cfg.Output.Format != "" {
309+
l.warn("The configuration option `output.format` is deprecated, please use `output.formats`")
310+
311+
var f OutputFormats
312+
err := f.UnmarshalText([]byte(l.cfg.Output.Format))
313+
if err != nil {
314+
return fmt.Errorf("unmarshal output format: %w", err)
315+
}
316+
317+
l.cfg.Output.Formats = f
318+
}
319+
320+
return nil
304321
}
305322

306323
func (l *Loader) handleEnableOnlyOption() error {

pkg/config/output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var AllOutputFormats = []string{
3535
}
3636

3737
type Output struct {
38-
Format string `mapstructure:"format"`
38+
Format string `mapstructure:"format"` // Deprecated: use Formats instead.
3939
Formats OutputFormats `mapstructure:"formats"`
4040
PrintIssuedLine bool `mapstructure:"print-issued-lines"`
4141
PrintLinterName bool `mapstructure:"print-linter-name"`

0 commit comments

Comments
 (0)