ruff/crates/ruff
Tobias Fischer 0ea2519e80
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.
2024-06-02 17:59:57 +00:00
..
resources/test/fixtures Rename `ruff_cli` crate to `ruff` (#9557) 2024-01-16 17:47:01 -05:00
src Add RDJson support. (#11682) 2024-06-02 17:59:57 +00:00
tests docs: Minor formatting typo in F401 example. (#11601) 2024-05-29 11:14:53 -04:00
Cargo.toml Bump version to v0.4.7 (#11646) 2024-05-31 16:30:36 -04:00
build.rs Rename `ruff_cli` crate to `ruff` (#9557) 2024-01-16 17:47:01 -05:00