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

Saving a specific message-format to a file, while also producing "normal" output #14555

Closed
BatmanAoD opened this issue Sep 17, 2024 · 2 comments
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. A-json-output Area: JSON message output C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.

Comments

@BatmanAoD
Copy link
Member

Problem

In CI, it can be useful to generate a code-quality report while also printing a job log designed for humans to read. cargo check provides --message-format json, which enables generating machine-readable output that can be used to generate a report programmatically (e.g. with https://crates.io/crates/gitlab_clippy); but currently, there's no way to do this in such a way that cargo also produces useful human-readable output. cargo clippy --message-format json | tee <file> is too verbose and difficult to read.

Because of this, gitlab_clippy recommends running cargo check twice in CI, once to produce readable output and fail the job if there are errors, and again to produce a report.

Proposed Solution

There could be an additional flag that would take a file argument and permit sending json messages to that file, while emitting the "normal" Cargo output on stdout.

Notes

No response

@BatmanAoD BatmanAoD added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Sep 17, 2024
@epage epage added A-console-output Area: Terminal output, colors, progress bar, etc. A-json-output Area: JSON message output S-needs-team-input Status: Needs input from team on whether/how to proceed. and removed S-triage Status: This issue is waiting on initial triage. labels Sep 19, 2024
@epage
Copy link
Contributor

epage commented Oct 8, 2024

https://crates.io/crates/gitlab_clippy);

Another similar conversion command: https://crates.io/crates/clippy-sarif

@ehuss
Copy link
Contributor

ehuss commented Oct 8, 2024

Thanks for the report! The cargo team discussed this and decided to close this for now. We suggest that, if possible, gitlab_clippy be responsible for printing the rendered output from the JSON messages. If there are events or other things missing from the JSON that would be useful, feel free to open a new issue for any missing messages (though I think we have a few currently open).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. A-json-output Area: JSON message output C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.
Projects
None yet
Development

No branches or pull requests

3 participants