Skip to content

Commit

Permalink
Move problem rendering to application
Browse files Browse the repository at this point in the history
  • Loading branch information
jodyheavener committed Mar 26, 2024
1 parent 88ec902 commit 945cb22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 10 additions & 0 deletions script/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ func (a *Application) IsValid() bool {
return len(a.Problems) == 0
}

func (a *Application) RenderProblems() string {
var problemStrings []string

for _, err := range a.Problems {
problemStrings = append(problemStrings, fmt.Sprintf("- %s", err.Error()))
}

return strings.Join(problemStrings, "\n")
}

func (a *Application) GetData() string {
data, err := json.MarshalIndent(a, "", "\t")
if err != nil {
Expand Down
14 changes: 1 addition & 13 deletions script/reviewer.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package main

import (
"fmt"
"log"
"strings"
)

type Reviewer struct {
Expand All @@ -25,21 +23,11 @@ func (r *Reviewer) Review() {
if r.application.IsValid() {
debugMessage("Application has no problems")
} else {
debugMessage("Application problems:", r.renderProblems())
debugMessage("Application problems:", r.application.RenderProblems())
}
}
}

func (r *Reviewer) printErrorAndExit(err error) {
log.Fatalf("Error reviewing issue: %s\n", err.Error())
}

func (r *Reviewer) renderProblems() string {
var problemStrings []string

for _, err := range r.application.Problems {
problemStrings = append(problemStrings, fmt.Sprintf("- %s", err.Error()))
}

return strings.Join(problemStrings, "\n")
}

0 comments on commit 945cb22

Please sign in to comment.