DeepSource now supports Rustfmt

Code formatting helps make your codebase easier to navigate and read. However, it is often difficult for programmers to devote time to code styling. Even though there are various code formatting tools, they are hard to integrate into your code review flow.

In addition to Analyzers, DeepSource supports Transformers as well. Transformers are a neat feature of DeepSource that format code on autopilot across your repositories, be it commits or pull requests. Forget about enforcing code style standards manually, and have DeepSource do it for you!

With the beta release of the Rust Analyzer, we also added support for the rustfmt Transformer. To have it integrate with your existing DeepSource flow, all you have to do is type in the following entry into .deepsource.toml :

[[transformers]]
name = "rustfmt"
enabled = true

If that is too much work, head over to Settings → Generate Configuration and select the rustfmt Transformer from the list:

enable_rustfmt

The typical Transformer workflow looks something like this:

  • If a pull/merge request is raised with the default branch as the base, a
    transforming commit is added to that branch.
  • If a commit is created on the default branch, DeepSource raises a pull/merge
    request with transforming changes.

The rustfmt Transformer respects your rustfmt.toml if it exists in the repository root, you don’t have to worry about additional configuration at all!

Want to know more about our Rust Analyzer? All the details are here!

2 Likes