mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Add RDJson support. (#11682)
## Summary Implement support for RDJson output for `ruff check`, as requested in #8655. ## Test Plan Tested using a snapshot test. Same approach as for e.g. the JSON output formatter. ## Additional info I tried to keep the implementation close to the JSON implementation. I had to deviate a bit to make the `suggestions` key work: If there are no suggestions, then setting `suggestions` to `null` is invalid according to the JSONSchema. Therefore, I opted for a slightly more complex implementation, that skips the `suggestions` key entirely if there are no fixes available for the given diagnostic. Maybe it would have been easier to set `"suggestions": []`, but I ended up doing it this way. I didn't consider notebooks, as I _think_ that RDJson doesn't work with notebooks. This should be confirmed, and if so, there should be some form of warning or error emitted when trying to output diagnostics for a notebook. I also didn't consider `ruff format`, as this comment: https://github.com/astral-sh/ruff/issues/8655#issuecomment-1811446160 suggests that that wouldn't be compatible. I'm new to Rust, any feedback is appreciated. 🙂 I implemented this in order to have a productive rainy saturday afternoon, I'm not knowledgeable about RDJson beyond the sources linked in the issue.
This commit is contained in:
parent
6d79ddc0aa
commit
0ea2519e80
7 changed files with 252 additions and 2 deletions
|
@ -515,6 +515,7 @@ pub enum SerializationFormat {
|
|||
Github,
|
||||
Gitlab,
|
||||
Pylint,
|
||||
Rdjson,
|
||||
Azure,
|
||||
Sarif,
|
||||
}
|
||||
|
@ -532,6 +533,7 @@ impl Display for SerializationFormat {
|
|||
Self::Github => write!(f, "github"),
|
||||
Self::Gitlab => write!(f, "gitlab"),
|
||||
Self::Pylint => write!(f, "pylint"),
|
||||
Self::Rdjson => write!(f, "rdjson"),
|
||||
Self::Azure => write!(f, "azure"),
|
||||
Self::Sarif => write!(f, "sarif"),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue