Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Dec 2, 2024
1 parent 57b2a1f commit 8786701
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions cli/render/renderer_terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ func (r *TerminalRenderer) Perfect(file string, report *check.Report) {

switch r.Format {
case "tiny":
fmtc.Printf("%s{s}:{!} {g}✔ {!}\n", fmtutil.Align(specName, fmtutil.RIGHT, r.FilenameSize+2))
fmtc.Printfn("%s{s}:{!} {g}✔ {!}", fmtutil.Align(specName, fmtutil.RIGHT, r.FilenameSize+2))
case "summary":
r.renderSummary(report)
default:
fmtc.Printf("{g}{*}%s.spec{!*} is perfect!{!}\n", specName)
fmtc.Printfn("{g}{*}%s.spec{!*} is perfect!{!}", specName)
}
}

Expand All @@ -86,9 +86,9 @@ func (r *TerminalRenderer) Skipped(file string, report *check.Report) {

switch r.Format {
case "tiny":
fmtc.Printf("%s{s}:{!} {s}—{!}\n", fmtutil.Align(specName, fmtutil.RIGHT, r.FilenameSize+2))
fmtc.Printfn("%s{s}:{!} {s}—{!}", fmtutil.Align(specName, fmtutil.RIGHT, r.FilenameSize+2))
default:
fmtc.Printf("{s}{*}%s.spec{!*} check skipped due to non-applicable target{!}\n", specName)
fmtc.Printfn("{s}{*}%s.spec{!*} check skipped due to non-applicable target{!}", specName)
}
}

Expand All @@ -100,8 +100,8 @@ func (r *TerminalRenderer) Error(file string, err error) {

switch r.Format {
case "tiny":
fmtc.Printf(
"%s{s}:{!} {r}✖ (%v){!}\n",
fmtc.Printfn(
"%s{s}:{!} {r}✖ (%v){!}",
fmtutil.Align(specName, fmtutil.RIGHT, r.FilenameSize+2), err,
)
default:
Expand Down Expand Up @@ -274,8 +274,8 @@ func (r *TerminalRenderer) renderHeader(level uint8, count int) {
fg := r.fgColor[level]
bg := r.bgColor[level]

fmtc.Printf(bg+" ••• %-83s{!}\n", header)
fmtc.Printf(fg + "│{!}\n")
fmtc.Printfn(bg+" ••• %-83s{!}", header)
fmtc.Printfn(fg + "│{!}")
}

// renderAlerts prints all alerts from given slice
Expand All @@ -286,7 +286,7 @@ func (r *TerminalRenderer) renderAlerts(level uint8, alerts []check.Alert) {
r.renderAlert(alert)

if index+1 < totalAlerts {
fmtc.Printf(r.fgColor[level] + "│{!}\n")
fmtc.Printfn(r.fgColor[level] + "│{!}")
}
}

Expand Down Expand Up @@ -317,17 +317,17 @@ func (r *TerminalRenderer) renderAlert(alert check.Alert) {
}

if alert.ID != "" {
fmtc.Printf(fg+"(%s) %s{!}\n", alert.ID, alert.Info)
fmtc.Printfn(fg+"(%s) %s{!}", alert.ID, alert.Info)
} else {
fmtc.Printf(fg+"(rpmlint) %s{!}\n", alert.Info)
fmtc.Printfn(fg+"(rpmlint) %s{!}", alert.Info)
}

if alert.Line.Text != "" {
text := strutil.Ellipsis(alert.Line.Text, 86)
if alert.IsIgnored {
fmtc.Printf(lc+"│ {s-}%s{!}\n", text)
fmtc.Printfn(lc+"│ {s-}%s{!}", text)
} else {
fmtc.Printf(lc+"│ {s}%s{!}\n", text)
fmtc.Printfn(lc+"│ {s}%s{!}", text)
}
}
}
Expand All @@ -345,7 +345,7 @@ func (r *TerminalRenderer) renderLinks(report *check.Report) {
fmtc.Println("\n{*}Links:{!}\n")

for _, id := range report.IDs() {
fmtc.Printf(" {s}•{!} %s%s\n", "https://kaos.sh/perfecto/w/", id)
fmtc.Printfn(" {s}•{!} %s%s", "https://kaos.sh/perfecto/w/", id)
}

fmtc.NewLine()
Expand Down Expand Up @@ -423,9 +423,9 @@ func (r *TerminalRenderer) renderShortAlert(alert check.Alert) {
}

if alert.ID != "" {
fmtc.Printf(fg+"(%s) %s{!}\n", alert.ID, alert.Info)
fmtc.Printfn(fg+"(%s) %s{!}", alert.ID, alert.Info)
} else {
fmtc.Printf(fg+"(rpmlint) %s{!}\n", alert.Info)
fmtc.Printfn(fg+"(rpmlint) %s{!}", alert.Info)
}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.8

require (
github.com/essentialkaos/check v1.4.1
github.com/essentialkaos/ek/v13 v13.13.1
github.com/essentialkaos/ek/v13 v13.14.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ github.com/essentialkaos/check v1.4.1 h1:SuxXzrbokPGTPWxGRnzy0hXvtb44mtVrdNxgPa1
github.com/essentialkaos/check v1.4.1/go.mod h1:xQOYwFvnxfVZyt5Qvjoa1SxcRqu5VyP77pgALr3iu+M=
github.com/essentialkaos/depsy v1.3.1 h1:00k9QcMsdPM4IzDaEFHsTHBD/zoM0oxtB5+dMUwbQa8=
github.com/essentialkaos/depsy v1.3.1/go.mod h1:B5+7Jhv2a2RacOAxIKU2OeJp9QfZjwIpEEPI5X7auWM=
github.com/essentialkaos/ek/v13 v13.13.1 h1:JuBlzEEzWDvrNVW+goKUTG+2eB+fVNf/RY0WhGoY3Co=
github.com/essentialkaos/ek/v13 v13.13.1/go.mod h1:GAoS44v5gtd3Yc1qqfgXsaJNoC0dMw1ueW5Fc9TTHUg=
github.com/essentialkaos/ek/v13 v13.14.0 h1:kBpA6r5wZxi09ND5vmlzpe9kvjfWSJ4AywBJM8Oq1ME=
github.com/essentialkaos/ek/v13 v13.14.0/go.mod h1:GAoS44v5gtd3Yc1qqfgXsaJNoC0dMw1ueW5Fc9TTHUg=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down

0 comments on commit 8786701

Please sign in to comment.