Skip to content

Commit

Permalink
fix(helper): display errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Sanvoisin committed Feb 1, 2024
1 parent eae8fe8 commit 05ccce8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 6 additions & 3 deletions checks/dry.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Dry() (data.Check, error) {
return dataCheck, err
}

duplicates := []string{}
duplicates := []data.Error{}
for _, layer := range layers {
// Get all files that are included with Terragrunt include block
files, _ := findFilesInLayers(layer)
Expand All @@ -47,8 +47,11 @@ func Dry() (data.Check, error) {
return dataCheck, err
}
for key, f := range findings {
errmsg := "Duplicate in file " + combination[0] + " and " + combination[1] + " --> " + key + ":" + f
duplicates = append(duplicates, errmsg)
duplicates = append(duplicates, data.Error{
Path: combination[0] + " and " + combination[1],
LineNumber: -1,
Description: key + ":" + f,
})
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions helpers/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ func RenderChecks(checkResults []data.Check, verbose bool) {
fmt.Printf("%s %s - %s\n", c.Status, c.ID, termlink.Link(c.Name, c.RelatedGuidelines))
if len(c.Errors) > 0 && verbose {
for _, err := range c.Errors {
fmt.Println(" - Path", err.Path)
if err.LineNumber != -1 {
fmt.Println(" Line number:", err.LineNumber)
// Display location of error
if err.LineNumber == -1 {
fmt.Println(" - ", err.Path)
} else {
fmt.Println(" - ", err.Path+":"+strconv.Itoa(err.LineNumber))
}
if err.Description != "" {
fmt.Println(" Description:", err.Description)
fmt.Println(" Description:", err.Description)

}
}
Expand Down

0 comments on commit 05ccce8

Please sign in to comment.