@@ -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 {
@@ -164,7 +167,7 @@ func (l *Loader) parseConfig() error {
164167 var configFileNotFoundError viper.ConfigFileNotFoundError
165168 if errors .As (err , & configFileNotFoundError ) {
166169 // Load configuration from flags only.
167- err = l .viper .Unmarshal (l .cfg )
170+ err = l .viper .Unmarshal (l .cfg , customDecoderHook () )
168171 if err != nil {
169172 return fmt .Errorf ("can't unmarshal config by viper (flags): %w" , err )
170173 }
@@ -181,7 +184,7 @@ func (l *Loader) parseConfig() error {
181184 }
182185
183186 // 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 {
185188 return fmt .Errorf ("can't unmarshal config by viper (flags, file): %w" , err )
186189 }
187190
@@ -279,28 +282,47 @@ func (l *Loader) handleGoVersion() {
279282 }
280283}
281284
282- func (l * Loader ) handleDeprecation () {
285+ func (l * Loader ) handleDeprecation () error {
286+ // Deprecated since v1.57.0
283287 if len (l .cfg .Run .SkipFiles ) > 0 {
284288 l .warn ("The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`." )
285289 l .cfg .Issues .ExcludeFiles = l .cfg .Run .SkipFiles
286290 }
287291
292+ // Deprecated since v1.57.0
288293 if len (l .cfg .Run .SkipDirs ) > 0 {
289294 l .warn ("The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`." )
290295 l .cfg .Issues .ExcludeDirs = l .cfg .Run .SkipDirs
291296 }
292297
293298 // The 2 options are true by default.
299+ // Deprecated since v1.57.0
294300 if ! l .cfg .Run .UseDefaultSkipDirs {
295301 l .warn ("The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`." )
296302 }
297303 l .cfg .Issues .UseDefaultExcludeDirs = l .cfg .Run .UseDefaultSkipDirs && l .cfg .Issues .UseDefaultExcludeDirs
298304
299305 // The 2 options are false by default.
306+ // Deprecated since v1.57.0
300307 if l .cfg .Run .ShowStats {
301308 l .warn ("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`" )
302309 }
303310 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
304326}
305327
306328func (l * Loader ) handleEnableOnlyOption () error {
@@ -332,13 +354,13 @@ func (l *Loader) warn(format string) {
332354 l .log .Warnf (format )
333355}
334356
335- func fileDecoderHook () viper.DecoderConfigOption {
357+ func customDecoderHook () viper.DecoderConfigOption {
336358 return viper .DecodeHook (mapstructure .ComposeDecodeHookFunc (
337359 // Default hooks (https://github.com/spf13/viper/blob/518241257478c557633ab36e474dfcaeb9a3c623/viper.go#L135-L138).
338360 mapstructure .StringToTimeDurationHookFunc (),
339361 mapstructure .StringToSliceHookFunc ("," ),
340362
341- // Needed for forbidigo.
363+ // Needed for forbidigo, and output.formats .
342364 mapstructure .TextUnmarshallerHookFunc (),
343365 ))
344366}
0 commit comments