Skip to content

Commit 3afe031

Browse files
committed
Fix linter finding with constant format
Fix linter finding with format function used without formatting.
1 parent eeecd0d commit 3afe031

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

output.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func NewOutputProcessor(useIndentLines bool, boldKeys bool, colorSchema *map[str
8181
}
8282
}
8383

84-
// Deprecated: Use colorizef instead
84+
// TODO Change signature to swap into the right order, color first, text second
8585
func (p *OutputProcessor) colorize(text string, colorName string) string {
8686
if p.colorSchema != nil {
8787
if value, ok := (*p.colorSchema)[colorName]; ok {
@@ -93,18 +93,11 @@ func (p *OutputProcessor) colorize(text string, colorName string) string {
9393
}
9494

9595
func (p *OutputProcessor) colorizef(colorName string, format string, a ...interface{}) string {
96-
var text = format
9796
if len(a) > 0 {
98-
text = fmt.Sprintf(format, a...)
97+
return p.colorize(fmt.Sprintf(format, a...), colorName)
9998
}
10099

101-
if p.colorSchema != nil {
102-
if value, ok := (*p.colorSchema)[colorName]; ok {
103-
return bunt.Style(text, bunt.Foreground(value))
104-
}
105-
}
106-
107-
return text
100+
return p.colorize(format, colorName)
108101
}
109102

110103
func (p *OutputProcessor) determineColorByType(obj interface{}) string {

output_yaml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func (p *OutputProcessor) neatYAMLofNode(prefix string, skipIndentOnFirstLine bo
285285
if needsQuotes(node) {
286286
fmt.Fprint(p.out, p.colorizef(colorName, `"%s"`, node.Value))
287287
} else {
288-
fmt.Fprint(p.out, p.colorizef(colorName, node.Value))
288+
fmt.Fprint(p.out, p.colorize(node.Value, colorName))
289289
}
290290

291291
default:

0 commit comments

Comments
 (0)