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

formatter(compact): print hcl.Diagnostics errors in compact format #1482

Merged
merged 2 commits into from
Aug 17, 2022

Conversation

bendrucker
Copy link
Member

When --formatter compact is set and an error occurs that is/wraps hcl.Diagnostics, print each diagnostic in a format similar to the format used for issues raised by rules. In an environment like GitHub Actions where output is matched and associated with lines in a PR, this could help show syntax errors that prevented TFLint's execution in the context that triggered them.

The JSON and Sarif formatters similarly handle hcl.Diagnostics and while there's not much boilerplate more code could definitely be shared among the formatters in the future.

Closes #1461

@bendrucker bendrucker changed the title formatter(compact): print hcl.Diagnostics error in compact format formatter(compact): print hcl.Diagnostics errors in compact format Aug 12, 2022
@bendrucker bendrucker requested a review from wata727 August 12, 2022 18:30
Copy link
Member

@wata727 wata727 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

My only concern is that this syntax error will look like an issue. In my experience, the next user reaction is "Why this warning cannot be suppressed with the tflint-ignore annotation?".

Similar to issues, there is a way to support ignoring hcl.Diagnostics by annotations, but it still makes more sense to treat hcl.Diagnostics as issues.

Still, I understand that this doesn't make things much worse, as the existing friendly error display is already misleading users. If this behavior misleads many users, it's better to return a simple fatal error.

@bendrucker
Copy link
Member Author

Good point, unlike Sarif/JSON it's fairly hard to tell when a compact-formatted line originates from a rule (issue) versus an error.

@bendrucker bendrucker merged commit 78480f8 into master Aug 17, 2022
@wata727 wata727 deleted the formatter-compact-errors branch May 2, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add compact formatting for errors
2 participants