meta
meta copied to clipboard
Add `rustfmt-check`
Would it be difficult to adapt clippy-check
to create rustfmt-check
?
There is the same --mesage-format=json
option for cargo fmt
, though currently it is in a bit of limbo on stable (rust-lang/rustfmt#3947).
I tried forking clippy-check
to create rustfmt-check
, but was unable to get npm to install the right dependencies and I'm not sure how things are meant to work. You can see the 'fork' at https://github.com/JP-Ellis/rustfmt-check and a test crate using it at https://github.com/JP-Ellis/test-rustfmt-check and if I'm on the right track, help would be appreciated.
Hi, @JP-Ellis! Well, yes, technically, there should be no difficulties, but I can't imagine any reason to do that so far, so it would help if you could elaborate a little bit more about your case.
clippy-check
provides information that can't be usually fixed by a machine, while formatting issues can be resolved with the rustfmt
call (manual or automatic, see #8) usually.
In what way we could benefit more from the rustfmt-check
Action instead of, let's say, implemented #8?
Well, I can see three ways in which rustfmt
can be used:
- Have
rustfmt-check
automatically create a commit and push it on top of pull requests, or automatically open pull requests for commits pushed. - Have
rustfmt-check
issue a warning if the commit is not formatted correctly with instructions as to how this can be done (in case the pull request is from someone new to rust). - Have
rustfmt-check
create a more extensive report detailing the changes that will happen, akin toclippy-check
.
Although I personally would use the first two options the most, it might be worth adding support for the last option especially in cases where some of the code should not be reformatted and there is a missing #[rustfmt::skip]
, or an error in the ignore section of rustfmt.toml
.
provides information that can't be usually fixed by a machine
Lots (most?) of the suggestions can actually be fixed with cargo fix
, so I'd argue same reasoning should apply.
And, either way, since we already have a cargo fmt
action that displays issues, I'd argue that improving visibility by showing these issues inline could be great.
I started working on an action based on the ideas presented in this issue: https://github.com/mbrobbel/rustfmt-check.