Reduce main complexity
thazelart opened this issue · 1 comments
thazelart commented
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())
}
}
}