Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Reduce main complexity #18

Closed
thazelart opened this issue Jul 26, 2019 · 1 comment
Closed

Reduce main complexity #18

thazelart opened this issue Jul 26, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@thazelart
Copy link
Owner

Problem

Main complexity is to high.

Solution

Extract the log code in a new internal/log package

Example of code to extract

if len(blockNamesErrors) > 0 || len(blocksInFilesErrors) > 0 || len(providersVersionErrors) > 0 {
	exitCode = 1
	fmt.Printf("\nERROR: %s misformed:\n", file.Path)
	if len(providersVersionErrors) > 0 {
		fmt.Printf("  Unversioned provider(s):\n")
		for _, err := range providersVersionErrors {
			fmt.Printf("    - %s\n", err.Error())
		}
	}
	if len(blockNamesErrors) > 0 {
		fmt.Printf("  Unmatching \"%s\" pattern blockname(s):\n",
			globalConfig.TerraformConfig.BlockPatternName)
		for _, err := range blockNamesErrors {
			fmt.Printf("    - %s\n", err.Error())
		}
	}
	if len(blocksInFilesErrors) > 0 {
		fmt.Println("  Unauthorized block(s):")
		for _, err := range blocksInFilesErrors {
			fmt.Printf("    - %s\n", err.Error())
		}
	}
}
@thazelart thazelart added the enhancement New feature or request label Jul 26, 2019
@thazelart thazelart self-assigned this Jul 26, 2019
@thazelart
Copy link
Owner Author

Fixed in 2.0.0 version (#26)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant