Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates lint output to print detail instead of description #5045

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonistiigi Is it needed to have the line number in progress as we already have this information in?:

Usage of undefined variable '$PAHT' (did you mean $PATH?)
Dockerfile:3
--------------------
   1 |     FROM alpine
   2 | >>> ENV PATH=$PAHT:/foo
   3 |
--------------------

Mostly looking at docker/actions-toolkit#365 (comment)

image

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is only with --debug. By default there is no source code view.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is not needed for example in your github actions excerpt. It should probably be added in buildx side for views that need it, not inside the string here.

}
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
Loading