Skip to content

Commit 945cb22

Browse files
committed
Move problem rendering to application
1 parent 88ec902 commit 945cb22

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

script/application.go

+10
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ func (a *Application) IsValid() bool {
109109
return len(a.Problems) == 0
110110
}
111111

112+
func (a *Application) RenderProblems() string {
113+
var problemStrings []string
114+
115+
for _, err := range a.Problems {
116+
problemStrings = append(problemStrings, fmt.Sprintf("- %s", err.Error()))
117+
}
118+
119+
return strings.Join(problemStrings, "\n")
120+
}
121+
112122
func (a *Application) GetData() string {
113123
data, err := json.MarshalIndent(a, "", "\t")
114124
if err != nil {

script/reviewer.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package main
22

33
import (
4-
"fmt"
54
"log"
6-
"strings"
75
)
86

97
type Reviewer struct {
@@ -25,21 +23,11 @@ func (r *Reviewer) Review() {
2523
if r.application.IsValid() {
2624
debugMessage("Application has no problems")
2725
} else {
28-
debugMessage("Application problems:", r.renderProblems())
26+
debugMessage("Application problems:", r.application.RenderProblems())
2927
}
3028
}
3129
}
3230

3331
func (r *Reviewer) printErrorAndExit(err error) {
3432
log.Fatalf("Error reviewing issue: %s\n", err.Error())
3533
}
36-
37-
func (r *Reviewer) renderProblems() string {
38-
var problemStrings []string
39-
40-
for _, err := range r.application.Problems {
41-
problemStrings = append(problemStrings, fmt.Sprintf("- %s", err.Error()))
42-
}
43-
44-
return strings.Join(problemStrings, "\n")
45-
}

0 commit comments

Comments
 (0)