[Chronik] Add `rustfmt` linter, to style check Rust files


[Chronik] Add rustfmt linter, to style check Rust files

Check formatting via rustfmt. Configuration is kept rusty, instead of mimicking clang-format.

During development, cargo +nightly fmt should be used to wrap comments, strings, group imports, etc. As these features are unstable and might have false-positives, we don't enforce on them in the CI yet.

Stable rustfmt currently doesn't enforce line length limits strictly, therefore we have to verify length outselves. We skip length limits that are fixed by rustfmt, however, the current approach leaves some false positives:

  • If two lines within one rustfmt diff exceed the limit,
  • one of them is fixed by rustfmt,
  • then for *both* will be issued a warning.

Since this both doesn't occur too often, and also should be fixed by the "recommended" (aka cargo +nightly fmt) approach, the trade-off of having a simple implementation seems worth it.

Also, if cargo fmt wraps more and more code successfully, these false positives should disappear.

Test Plan:

  1. arc lint displays four errors, one being a false positive in line 12.
  2. arc lint will have only fit the spaces after struct.
  3. cargo +nightly fmt fixes all errors except the line having way too many x's.

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D11671


tobias_ruckAuthored on Jun 27 2022, 13:58
tobias_ruckPushed on Jul 1 2022, 21:28
Restricted Project
Differential Revision
D11671: [Chronik] Add `rustfmt` linter, to style check Rust files
rABC17107efbb5c3: [avalanche] Correctly flag the inflight compact proofs request