@@ -61,7 +61,10 @@ func (l *Loader) Load() error {
61
61
62
62
l .handleGoVersion ()
63
63
64
- l .handleDeprecation ()
64
+ err = l .handleDeprecation ()
65
+ if err != nil {
66
+ return err
67
+ }
65
68
66
69
err = l .handleEnableOnlyOption ()
67
70
if err != nil {
@@ -164,7 +167,7 @@ func (l *Loader) parseConfig() error {
164
167
var configFileNotFoundError viper.ConfigFileNotFoundError
165
168
if errors .As (err , & configFileNotFoundError ) {
166
169
// Load configuration from flags only.
167
- err = l .viper .Unmarshal (l .cfg )
170
+ err = l .viper .Unmarshal (l .cfg , customDecoderHook () )
168
171
if err != nil {
169
172
return fmt .Errorf ("can't unmarshal config by viper (flags): %w" , err )
170
173
}
@@ -181,7 +184,7 @@ func (l *Loader) parseConfig() error {
181
184
}
182
185
183
186
// Load configuration from all sources (flags, file).
184
- if err := l .viper .Unmarshal (l .cfg , fileDecoderHook ()); err != nil {
187
+ if err := l .viper .Unmarshal (l .cfg , customDecoderHook ()); err != nil {
185
188
return fmt .Errorf ("can't unmarshal config by viper (flags, file): %w" , err )
186
189
}
187
190
@@ -279,28 +282,47 @@ func (l *Loader) handleGoVersion() {
279
282
}
280
283
}
281
284
282
- func (l * Loader ) handleDeprecation () {
285
+ func (l * Loader ) handleDeprecation () error {
286
+ // Deprecated since v1.57.0
283
287
if len (l .cfg .Run .SkipFiles ) > 0 {
284
288
l .warn ("The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`." )
285
289
l .cfg .Issues .ExcludeFiles = l .cfg .Run .SkipFiles
286
290
}
287
291
292
+ // Deprecated since v1.57.0
288
293
if len (l .cfg .Run .SkipDirs ) > 0 {
289
294
l .warn ("The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`." )
290
295
l .cfg .Issues .ExcludeDirs = l .cfg .Run .SkipDirs
291
296
}
292
297
293
298
// The 2 options are true by default.
299
+ // Deprecated since v1.57.0
294
300
if ! l .cfg .Run .UseDefaultSkipDirs {
295
301
l .warn ("The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`." )
296
302
}
297
303
l .cfg .Issues .UseDefaultExcludeDirs = l .cfg .Run .UseDefaultSkipDirs && l .cfg .Issues .UseDefaultExcludeDirs
298
304
299
305
// The 2 options are false by default.
306
+ // Deprecated since v1.57.0
300
307
if l .cfg .Run .ShowStats {
301
308
l .warn ("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`" )
302
309
}
303
310
l .cfg .Output .ShowStats = l .cfg .Run .ShowStats || l .cfg .Output .ShowStats
311
+
312
+ // Deprecated since v1.57.0
313
+ if l .cfg .Output .Format != "" {
314
+ l .warn ("The configuration option `output.format` is deprecated, please use `output.formats`" )
315
+
316
+ var f OutputFormats
317
+ err := f .UnmarshalText ([]byte (l .cfg .Output .Format ))
318
+ if err != nil {
319
+ return fmt .Errorf ("unmarshal output format: %w" , err )
320
+ }
321
+
322
+ l .cfg .Output .Formats = f
323
+ }
324
+
325
+ return nil
304
326
}
305
327
306
328
func (l * Loader ) handleEnableOnlyOption () error {
@@ -332,13 +354,13 @@ func (l *Loader) warn(format string) {
332
354
l .log .Warnf (format )
333
355
}
334
356
335
- func fileDecoderHook () viper.DecoderConfigOption {
357
+ func customDecoderHook () viper.DecoderConfigOption {
336
358
return viper .DecodeHook (mapstructure .ComposeDecodeHookFunc (
337
359
// Default hooks (https://github.com/spf13/viper/blob/518241257478c557633ab36e474dfcaeb9a3c623/viper.go#L135-L138).
338
360
mapstructure .StringToTimeDurationHookFunc (),
339
361
mapstructure .StringToSliceHookFunc ("," ),
340
362
341
- // Needed for forbidigo.
363
+ // Needed for forbidigo, and output.formats .
342
364
mapstructure .TextUnmarshallerHookFunc (),
343
365
))
344
366
}
0 commit comments