Skip to content

Commit b2947c5

Browse files
committed
Apply format set in config file
1 parent f92cc22 commit b2947c5

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

cmd/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (cli *CLI) Run(args []string) int {
6464
cli.formatter = &formatter.Formatter{
6565
Stdout: cli.outStream,
6666
Stderr: cli.errStream,
67+
// NOTE: The format may be set in config file, but the flag will take precedence until it is loaded.
6768
Format: opts.Format,
6869
Fix: opts.Fix,
6970
}

cmd/inspect.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ func (cli *CLI) inspectModule(opts Options, dir string, filterFiles []string) (t
9393
return issues, changes, fmt.Errorf("Failed to load TFLint config; %w", err)
9494
}
9595
cli.config.Merge(opts.toConfig())
96+
// Apply format set in config file
97+
cli.formatter.Format = cli.config.Format
9698

9799
// Setup loader
98100
cli.loader, err = terraform.NewLoader(afero.Afero{Fs: afero.NewOsFs()}, cli.originalWorkingDir)

cmd/inspect_parallel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ func (cli *CLI) inspectParallel(opts Options) int {
9090
force = *opts.Force
9191
}
9292

93+
// Parallel inspection ignores the format set in the config file
94+
// and the --format CLI flag always takes precedence.
9395
if err := cli.formatter.PrintParallel(issues, cli.sources); err != nil {
9496
return ExitCodeError
9597
}

0 commit comments

Comments
 (0)