-
Notifications
You must be signed in to change notification settings - Fork 253
feat: Add support for --sarif
flag to qlty smells
command
#2037
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
feat: Add support for --sarif
flag to qlty smells
command
#2037
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
I agree there's no good reason that qlty check
supports --sarif
but qlty smells
does not, so I think this is a good feature.
In the future, we are going to be extracting the maintainability analysis that is in qlty smells
and qlty metrics
into a separate crate so that it can integrate more cleanly. This will have then effect of avoiding these kinds of issues. But the timeline for that is not set yet and this is helpful in the meantime.
As far as the design goes, I would try and avoid introducing a trait. What if we update the SarifFormatter
struct so that instead of storing a Report
as its fields it instead stores Vec<Message>
and Vec<Issue>
?
Hey @brynary, thanks for the suggestion! It really makes sense and actually simplifies the code. 🙂 Not sure why I didn’t go that route initially, probably didn’t want to touch the original interfaces. Anyway, I’ve pushed your suggestions. Hope it looks better now! ) |
hopefully fixed tests, added missed import |
a90f180
to
2de2710
Compare
2de2710
to
8afeb9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Will merge shortly.
This PR adds support for generating SARIF output using the --sarif flag when running the
qlty smells
command.Notes:
I'm not an expert in Rust, and I encountered a few challenges while implementing this feature, so happy for any comments to improve it.
The main issue was that the existing
SarifFormatter
only supported a single type:qlty_check::Report
. Since Rust doesn't have inheritance, I resolved this by extracting a shared trait (SarifTrait
) and implementing it for bothqlty_check::Report
andqlty_analysis::Report
. TheSarifFormatter
was then updated to accept any type that implements this trait.I'm not completely confident that all the structs and traits are placed in the most appropriate modules, so I'm open to feedback or suggestions about how to better organize them according to project conventions or best practices.