Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add triggered config description to docs #1375

Merged
merged 4 commits into from
May 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/users/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,29 @@ rules = [
]
DisableSyntax.noFinalize = true
```

## Triggered configuration

When Scalafix is triggered automatically (`scalafixOnCompile := true`), the
values for keys prefixed with `triggered` takes precedence over the default
configuration - both for rules and rule-specific configuration. You can think
of `triggered` as a optional overlay, on top of the default configuration.

For example, with the following configuration, explicit scalafix invocation
will run `DisableSyntax` & `RemoveUnused`, while triggered invocations
will only run `DisableSyntax`. In both cases, the `noFinalize` configuration
is enabled.

```scala
// .scalafix.conf
rules = [
DisableSyntax,
RemoveUnused
]
DisableSyntax.noFinalize = true

// `rules` on compilation
triggered.rules = [
DisableSyntax
]
```
9 changes: 6 additions & 3 deletions docs/users/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,22 @@ feature with care as it has several shortcomings, for example:
is the first task executed, without any other concurrently.
1. Some rules such as `RemoveUnused` can be counter-productive if applied too
often/early, as the work-in-progress code that was just added might disappear
after a simple `test`.
after a simple `test`.
To make such invocations less intrusive, you can change the rules and rules
configuration used in that case by defining in `.scalafix.conf`
[custom values for them](configuration.md#triggered-configuration).
1. If you run many semantic rules by default, the last one(s) to run might see
stale information and fail the invocation, which needs to be re-run manually.
This is [not specific to `scalafixOnCompile`](https://github.com/scalacenter/scalafix/issues/1204),
but the problem becomes much more visible with it.
1. To keep the overhad minimal, `scalafixCaching` is automatically enabled when
1. To keep the overhead minimal, `scalafixCaching` is automatically enabled when
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

`scalafixOnCompile` is, which can cause unexpected behaviors if you run into
false positive cache hits. `scalafixCaching` can explicitly be set to
`false` in that case.
1. Non-idempotent rewrite rules might get you in an infinite loop where sources
never converge - not specific to `scalafixOnCompile` either, but rather
confusing when triggered automatically.
1. Bugs in rule implementations can prevent you from getting a successul
1. Bugs in rule implementations can prevent you from getting a successful
bjaglin marked this conversation as resolved.
Show resolved Hide resolved
`compile`, blocking testing or publishing for example

### Run custom rules
Expand Down