Skip to content

Commit

Permalink
Fix linter finding with constant format
Browse files Browse the repository at this point in the history
Fix linter finding with format function used without formatting.
  • Loading branch information
HeavyWombat committed Jan 7, 2025
1 parent eeecd0d commit 3afe031
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewOutputProcessor(useIndentLines bool, boldKeys bool, colorSchema *map[str
}
}

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

func (p *OutputProcessor) colorizef(colorName string, format string, a ...interface{}) string {
var text = format
if len(a) > 0 {
text = fmt.Sprintf(format, a...)
return p.colorize(fmt.Sprintf(format, a...), colorName)
}

if p.colorSchema != nil {
if value, ok := (*p.colorSchema)[colorName]; ok {
return bunt.Style(text, bunt.Foreground(value))
}
}

return text
return p.colorize(format, colorName)
}

func (p *OutputProcessor) determineColorByType(obj interface{}) string {
Expand Down
2 changes: 1 addition & 1 deletion output_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (p *OutputProcessor) neatYAMLofNode(prefix string, skipIndentOnFirstLine bo
if needsQuotes(node) {
fmt.Fprint(p.out, p.colorizef(colorName, `"%s"`, node.Value))
} else {
fmt.Fprint(p.out, p.colorizef(colorName, node.Value))
fmt.Fprint(p.out, p.colorize(node.Value, colorName))
}

default:
Expand Down

0 comments on commit 3afe031

Please sign in to comment.