Skip to content

Commit

Permalink
Updates lint output to print detail instead of description
Browse files Browse the repository at this point in the history
Signed-off-by: Talon Bowler <talon.bowler@docker.com>
  • Loading branch information
daghack committed Jun 17, 2024
1 parent 5642608 commit 9305c60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions frontend/dockerfile/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ func (rule *LinterRule[F]) Run(warn LintWarnFunc, location []parser.Range, txt .
warn(rule.Name, rule.Description, rule.URL, short, location)
}

func LintFormatShort(rulename, msg string, startLine int) string {
return fmt.Sprintf("%s: %s (line %d)", rulename, msg, startLine)
func LintFormatShort(rulename, msg string, line int) string {
msg = fmt.Sprintf("%s: %s", rulename, msg)
if line > 0 {
msg = fmt.Sprintf("%s (line %d)", msg, line)
}
return msg
}

type LintWarnFunc func(rulename, description, url, fmtmsg string, location []parser.Range)
2 changes: 1 addition & 1 deletion frontend/subrequests/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func PrintLintViolations(dt []byte, w io.Writer) error {
if warning.URL != "" {
fmt.Fprintf(w, " - %s", warning.URL)
}
fmt.Fprintf(w, "\n%s\n", warning.Description)
fmt.Fprintf(w, "\n%s\n", warning.Detail)

if warning.Location.SourceIndex < 0 {
continue
Expand Down

0 comments on commit 9305c60

Please sign in to comment.