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

Print lint warnings #4761

Merged
merged 3 commits into from
Apr 11, 2024
Merged

Print lint warnings #4761

merged 3 commits into from
Apr 11, 2024

Conversation

daghack
Copy link
Collaborator

@daghack daghack commented Mar 13, 2024

Following on the footsteps of #4759, this adds support for an additional subrequest frontends can choose to implement for exposing linting errors and implements this subrequest for the dockerfile frontend.

@daghack daghack force-pushed the print-lint-warnings branch from 51b246b to 72d7aa7 Compare April 9, 2024 21:29
@daghack daghack marked this pull request as ready for review April 9, 2024 21:30
@daghack daghack requested a review from tonistiigi April 9, 2024 21:34
frontend/dockerfile/dockerfile2llb/convert.go Outdated Show resolved Hide resolved
frontend/dockerfile/dockerfile_test.go Outdated Show resolved Hide resolved
frontend/dockerfile/dockerfile_lint_test.go Outdated Show resolved Hide resolved
frontend/subrequests/lint/lint.go Show resolved Hide resolved
return res, nil
}

func PrintLintViolations(dt []byte, w io.Writer) error {
Copy link
Member

Choose a reason for hiding this comment

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

@colinhemmings Any comments about the output here?

@daghack daghack force-pushed the print-lint-warnings branch from f5fa4fd to aec4bda Compare April 10, 2024 05:35
@daghack daghack force-pushed the print-lint-warnings branch from aec4bda to 81fc6a3 Compare April 10, 2024 05:38
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

PTAL some failed validation in CI as well.

frontend/dockerfile/dockerfile2llb/convert.go Outdated Show resolved Hide resolved
frontend/dockerfile/dockerfile2llb/convert.go Outdated Show resolved Hide resolved
frontend/dockerfile/dockerfile_lint_test.go Outdated Show resolved Hide resolved
frontend/subrequests/lint/lint.go Outdated Show resolved Hide resolved
frontend/subrequests/lint/lint.go Outdated Show resolved Hide resolved
@daghack daghack force-pushed the print-lint-warnings branch from ced11ee to 543112e Compare April 10, 2024 16:03
@daghack
Copy link
Collaborator Author

daghack commented Apr 10, 2024

@tonistiigi Ready for a second review, at your leisure! 😃

@daghack daghack force-pushed the print-lint-warnings branch from 543112e to c772ed1 Compare April 11, 2024 00:23
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

Follow-up: The lint results and the warning summary in progressbar can appear out of order atm and warnings from later lines appearing after warning from first line. I think we should sort them based on the source code location before showing in a list.

frontend/dockerfile/dockerfile_test.go Outdated Show resolved Hide resolved
frontend/subrequests/lint/lint.go Outdated Show resolved Hide resolved
fmt.Fprintf(tw, "\t%s:%d\n", source.Filename, firstRange.Start.Line)
}
fmt.Fprintf(tw, "\t%s\n", warning.Detail)
for _, r := range warning.Location.Ranges {
Copy link
Member

Choose a reason for hiding this comment

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

Follow-up:

The source stacktrace doesn't seem to match the style in the progressbar:

Lint Rule FromAsCasing
  Dockerfile:1
  Lint Rule 'FromAsCasing': 'as' and 'FROM' keywords' casing do not match (line 1)
  1  |  FROM alpine as Base
 - Lint Rule 'FromAsCasing': 'as' and 'FROM' keywords' casing do not match (line 1)
The 'as' keyword should match the case of the 'from' keyword
Dockerfile:1
--------------------
   1 | >>> FROM alpine as Base
   2 |     RUN apk add git
   3 |     workdir /
--------------------

Copy link
Member

Choose a reason for hiding this comment

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

Also, note that this description part is missing in print output. Is this intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It ended up being a lot of redundant information displayed and looked pretty cluttered. That being said, getting them to match the much superior progressbar style is an EXCELLENT idea. 😂

@daghack daghack force-pushed the print-lint-warnings branch from c772ed1 to e81c6c6 Compare April 11, 2024 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants