Overview
DeepSource offers more than just issue detection. It also provides an automated source code formatting feature through Transformers.
Each commit in a repository is processed by a DeepSource Transformer, which applies industry-standard code formatters to ensure that the code is consistently formatted and free of conflicts. This automated formatting process helps maintain the quality of your codebase by ensuring that it adheres to established standards.
When a pull request (PR) is generated, all the enabled transformers specified in the .deepsource.toml
configuration file are executed. Any changes that are detected are then committed back to the same branch.
In cases where changes are made directly to the default branch without a pull request, a new pull request is automatically generated with the necessary transformations. This process ensures that any code changes made to the repository are consistently formatted and meet established standards, regardless of the method of modification.
GitHub imposes restrictions on creating commits on branches from other forks, which may occasionally prevent changes from being committed back. In such cases, we recommend merging the pull request as it is. Once the pull request is merged, DeepSource automatically identifies and incorporates the formatting transformations introduced in the merge commit.
When transformers are initially added to the .deepsource.toml
file on the default branch, the entire codebase is transformed. However, subsequent to this initial transformation, only files that have been added or modified in a commit, pull request, or merge request are transformed.
It should be noted that for pull requests that have non-default branches as their base (such as pull requests to release branches), transformations are not executed.
Supported Transformers
The following table lists all the supported Transformers.
Transformer | Shortcode | Version |
---|---|---|
Autopep8 | autopep8 | 2.0.4 |
Black | black | 24.2.0 |
Isort | isort | 5.13.2 |
Gofmt | gofmt | Go 1.21.7 |
0.6.0 | gofumpt | 0.6.0 |
rustfmt | rustfmt | 1.7.0-nightly |
Prettier | prettier | 3.2.5 |
RuboCop | rubocop | 1.52.1 |
Scalafmt | scalafmt | 3.5.9 |
StandardJS | standardjs | 17.1.0 |
StandardRB | standardrb | 1.29.0 |
Yapf | yapf | 0.40.2 |
Google Java Format | google-java-format | 1.17.0 |
dotnet-format | dotnet-format | .NET SDK 8.0 |
clang-format | clang-format | 18.1.1 |
PHP CS Fixer | php-cs-fixer | 3.51.0 |
Ktlint | ktlint | 0.50.0 |
swift-format | swift-format | 508.0.1 |
Ruff Formatter | ruff | 0.3.2 |