From 0dea4e7f46d538aa665c52feab99632c18b13ef2 Mon Sep 17 00:00:00 2001 From: Taisuke Oe Date: Wed, 21 Apr 2021 00:09:06 +0900 Subject: [PATCH 1/4] add triggered config description to docs --- docs/users/configuration.md | 19 +++++++++++++++++++ docs/users/installation.md | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/users/configuration.md b/docs/users/configuration.md index 61e5154ac..13979bcd9 100644 --- a/docs/users/configuration.md +++ b/docs/users/configuration.md @@ -31,3 +31,22 @@ rules = [ ] DisableSyntax.noFinalize = true ``` + +## Triggered configuration + +Overlay rules and rule specific configuration for scalafix on compilation, which is enabled by `scalafixOnCompile := true`. +Every configuration can be overlaid by `triggered` prefix. With the following configuration, explicit scalafix invocation will run with `[ DisableSyntax, RemoveUnused ]` rules, while scalafix on compilation will run with `[ DisableSyntax ]` rule. + +```scala +// .scalafix.conf +rules = [ + DisableSyntax, + RemoveUnused +] +DisableSyntax.noFinalize = true + +// `rules` on compilation +triggered.rules = [ + DisableSyntax +] +``` \ No newline at end of file diff --git a/docs/users/installation.md b/docs/users/installation.md index fbd4dc6a1..7f8b07a98 100644 --- a/docs/users/installation.md +++ b/docs/users/installation.md @@ -231,7 +231,9 @@ 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`. + `triggered` prefix in `.scalafix.conf` will help you to run scalafix on compile + with different configuration than explicit invocation. 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), @@ -243,7 +245,7 @@ feature with care as it has several shortcomings, for example: 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 `compile`, blocking testing or publishing for example ### Run custom rules From abbd352775fd3b044628a1e6435dfffca943b047 Mon Sep 17 00:00:00 2001 From: Taisuke Oe Date: Wed, 21 Apr 2021 11:51:39 +0900 Subject: [PATCH 2/4] Update docs/users/installation.md Co-authored-by: Brice Jaglin --- docs/users/installation.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/users/installation.md b/docs/users/installation.md index 7f8b07a98..0b6339980 100644 --- a/docs/users/installation.md +++ b/docs/users/installation.md @@ -232,8 +232,9 @@ feature with care as it has several shortcomings, for example: 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`. - `triggered` prefix in `.scalafix.conf` will help you to run scalafix on compile - with different configuration than explicit invocation. + 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), From 51130ef15e58e992f905575a357b3e071bd2a500 Mon Sep 17 00:00:00 2001 From: Taisuke Oe Date: Wed, 21 Apr 2021 11:51:49 +0900 Subject: [PATCH 3/4] Update docs/users/configuration.md Co-authored-by: Brice Jaglin --- docs/users/configuration.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/users/configuration.md b/docs/users/configuration.md index 13979bcd9..51e48cc36 100644 --- a/docs/users/configuration.md +++ b/docs/users/configuration.md @@ -34,8 +34,15 @@ DisableSyntax.noFinalize = true ## Triggered configuration -Overlay rules and rule specific configuration for scalafix on compilation, which is enabled by `scalafixOnCompile := true`. -Every configuration can be overlaid by `triggered` prefix. With the following configuration, explicit scalafix invocation will run with `[ DisableSyntax, RemoveUnused ]` rules, while scalafix on compilation will run with `[ DisableSyntax ]` rule. +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 @@ -49,4 +56,4 @@ DisableSyntax.noFinalize = true triggered.rules = [ DisableSyntax ] -``` \ No newline at end of file +``` From ccd95159883fd9175aefdc55fdbeace48884b86a Mon Sep 17 00:00:00 2001 From: Taisuke Oe Date: Wed, 21 Apr 2021 11:56:29 +0900 Subject: [PATCH 4/4] fix typo --- docs/users/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/users/installation.md b/docs/users/installation.md index 0b6339980..ca22ae2f8 100644 --- a/docs/users/installation.md +++ b/docs/users/installation.md @@ -239,7 +239,7 @@ feature with care as it has several shortcomings, for example: 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 `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.