Skip to content

Commit b6943bf

Browse files
authored
Merge pull request #2225 from scalacenter/installation-tweaks
docs: minor tweaks on installation.md
2 parents c2bf18d + ac9522a commit b6943bf

File tree

1 file changed

+43
-38
lines changed

1 file changed

+43
-38
lines changed

docs/users/installation.md

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Note that other setups may work, but could result in unexpected behavior.
1515

1616
## sbt
1717

18-
Start by installing the sbt 1.4+ plugin in `project/plugins.sbt`
18+
Start by installing the sbt 1.4+ plugin in `project/plugins.sbt`:
1919

2020
```scala
2121
// project/plugins.sbt
@@ -24,15 +24,15 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "@VERSION@")
2424

2525
> Scalafix is no longer published for Scala 2.11. You can run the final version
2626
> of Scalafix supporting 2.11, but all features documented below might not be
27-
> supported.
27+
> supported:
2828
> ```scala
2929
> // project/plugins.sbt
3030
> addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4") // final Scala 2.11 version
3131
> ```
3232
3333
> sbt-scalafix is no longer published for sbt 0.13.x. You should be able to run
3434
> the latest version of Scalafix with the final sbt-scalafix version published
35-
> for sbt 0.13.x, but all features documented below might not be supported.
35+
> for sbt 0.13.x, but all features documented below might not be supported:
3636
>
3737
> ```scala
3838
> // project/plugins.sbt
@@ -42,7 +42,7 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "@VERSION@")
4242
4343
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/ch.epfl.scala/sbt-scalafix/badge.svg)](https://maven-badges.herokuapp.com/maven-central/ch.epfl.scala/sbt-scalafix)
4444
45-
From the sbt shell, let's run the rule `ProcedureSyntax`
45+
From the sbt shell, let's run the rule `ProcedureSyntax`:
4646
4747
```
4848
> myproject / scalafix ProcedureSyntax
@@ -52,14 +52,14 @@ It's normal that the first invocation of `scalafix` takes a while to download
5252
Scalafix artifacts from Maven Central.
5353
5454
If all went well and your project uses the deprecated "procedure syntax", you
55-
should have a diff in your sources like this
55+
should have a diff in your sources like this:
5656
5757
```diff
5858
- def myProcedure {
5959
+ def myProcedure: Unit = {
6060
```
6161

62-
Next, if we run another rule like `RemoveUnused` then we get an error
62+
Next, if we run another rule like `RemoveUnused` then we get an error:
6363

6464
```
6565
> myproject / scalafix RemoveUnused
@@ -71,11 +71,10 @@ problem, update your build to add -Ywarn-unused-import (with 2.12) ...
7171
```
7272

7373
The first error message means the
74-
[SemanticDB](https://scalameta.org/docs/semanticdb/guide.html) compiler plugin
75-
is not enabled for this project. The second error says `RemoveUnused` requires
76-
77-
the Scala compiler option `-Ywarn-unused-import` (or `-Wunused:imports` in
78-
2.13.x or 3.x). To fix both problems, add the following settings to `build.sbt`
74+
[SemanticDB](https://scalameta.org/docs/semanticdb/guide.html) compiler output
75+
is not enabled for this project. The second error says that `RemoveUnused`
76+
requires the Scala compiler option `-Ywarn-unused-import` (or `-Wunused:imports`
77+
in 2.13.x or 3.x). To fix both problems, add the following settings to `build.sbt`:
7978

8079
```diff
8180
/*
@@ -124,15 +123,15 @@ For `project/*.scala` files, add
124123
`import scalafix.sbt.ScalafixPlugin.autoImport._` to the top of the file to
125124
resolve `scalafixSemanticdb`.
126125

127-
We run `RemoveUnused` again and the error is now gone
126+
We run `RemoveUnused` again and the error is now gone:
128127

129128
```
130129
> myproject / scalafix RemoveUnused
131130
[info] Compiling 15 Scala sources to ...
132131
[info] Running scalafix on 15 Scala sources
133132
```
134133

135-
If your project has unused imports, you should see a diff like this
134+
If your project has unused imports, you should see a diff like this:
136135

137136
```diff
138137
- import scala.util.{ Success, Failure }
@@ -184,7 +183,7 @@ The task `myproject / scalafix` runs for **main sources** in the project
184183
By default, the `scalafix` command is enabled for the `Compile` and `Test`
185184
configurations, and `scalafixAll` will run on both of them. To enable
186185
Scalafix for other configuration like `IntegrationTest`, add the following
187-
to your project settings
186+
to your project settings:
188187
189188
```diff
190189
lazy val myproject = project
@@ -219,7 +218,7 @@ fetch Scalafix artifacts from Maven Central. These artifacts are by default
219218
cached [inside the home directory](https://get-coursier.io/docs/cache.html#default-location).
220219
To avoid redundant downloads on every pull request, it's recommended to configure
221220
your CI enviroment to cache this directory. The location can be customized with
222-
the environment variable `COURSIER_CACHE`
221+
the environment variable `COURSIER_CACHE`:
223222

224223
```sh
225224
export COURSIER_CACHE=$HOME/.custom-cache
@@ -240,7 +239,7 @@ feature with care as it has several shortcomings, for example:
240239
before a call to `scalafix[All] --check`, causing this one to run on dirty
241240
sources and thus pass while it should not. Make sure that `scalafixOnCompile`
242241
is disabled on CI or, if that is impossible, that `scalafix[All] --check`
243-
is the first task executed, without any other concurrently.
242+
is the first task executed, without any other at the same time.
244243
1. Some rules such as `RemoveUnused` can be counter-productive if applied too
245244
often/early, as the work-in-progress code that was just added might disappear
246245
after a simple `test`.
@@ -251,13 +250,9 @@ feature with care as it has several shortcomings, for example:
251250
stale information and fail the invocation, which needs to be re-run manually.
252251
This is [not specific to `scalafixOnCompile`](https://github.com/scalacenter/scalafix/issues/1204),
253252
but the problem becomes much more visible with it.
254-
1. To keep the overhead minimal, `scalafixCaching` is automatically enabled when
255-
`scalafixOnCompile` is, which can cause unexpected behaviors if you run into
256-
false positive cache hits. `scalafixCaching` can explicitly be set to
257-
`false` in that case.
258253
1. Non-idempotent rewrite rules might get you in an infinite loop where sources
259-
never converge - not specific to `scalafixOnCompile` either, but rather
260-
confusing when triggered automatically.
254+
never converge - not specific to `scalafixOnCompile`, but rather confusing
255+
when triggered automatically.
261256
1. Bugs in rule implementations can prevent you from getting a successful
262257
`compile`, blocking testing or publishing for example
263258

@@ -295,13 +290,13 @@ If all went well, you should see a diff adding the comment
295290
By default, the SemanticDB compiler plugin will process all files in a project.
296291

297292
Use `-P:semanticdb:exclude:<regex>` to exclude files from the SemanticDB
298-
compiler plugin.
293+
compiler plugin:
299294

300295
```scala
301296
scalacOptions += "-P:semanticdb:exclude:Macros.scala"
302297
```
303298

304-
Separate multiple patterns with pipe `|` to exclude multiple files.
299+
Separate multiple patterns with pipe `|` to exclude multiple files:
305300

306301
```scala
307302
scalacOptions += "-P:semanticdb:exclude:Macros.scala|Schema.scala"
@@ -322,7 +317,7 @@ Scala 2.x, the `scalafix` task also respects
322317
[`-P:semanticdb:exclude`](#exclude-files-from-semanticdb-scala-2x-only).
323318

324319
Use `Compile / scalafix / unmanagedSources` to optionally exclude files from
325-
the `scalafix` task.
320+
the `scalafix` task:
326321

327322
```scala
328323
Compile / scalafix / unmanagedSources :=
@@ -339,15 +334,15 @@ The `*.semanticdb` files are available in the directory referenced by the
339334
`semanticdbTargetRoot` key, which defaults to `target/scala-x/meta`.
340335

341336
You can override this default to emit `*.semanticdb` files in a custom
342-
location. For example:
337+
location:
343338

344339
```scala
345340
semanticdbTargetRoot := target.value / "semanticdb"
346341
```
347342

348343
Alternatively, you can set the `semanticdbIncludeInJar` key to request
349344
the compiler to emit these files into the `classDirectory` so that they
350-
are available in packaged JARs.
345+
are available in packaged JARs:
351346

352347
```scala
353348
semanticdbIncludeInJar := true
@@ -356,7 +351,7 @@ semanticdbIncludeInJar := true
356351
### Disable Scalafix for specific project
357352

358353
Use `.disablePlugins(ScalafixPlugin)` to disable Scalafix for a particular
359-
project.
354+
project:
360355

361356
```diff
362357
lazy val myproject = project
@@ -365,7 +360,7 @@ project.
365360
```
366361

367362
When using Scala.js or Scala Native, use `.jsConfigure` or `.nativeConfigure` to
368-
disable Scalafix for only the Scala.js or Scala Native project. For example:
363+
disable Scalafix for only the Scala.js or Scala Native project:
369364

370365
```diff
371366
lazy val myproject = crossProject(JVMPlatform, JSPlatform)
@@ -377,7 +372,7 @@ disable Scalafix for only the Scala.js or Scala Native project. For example:
377372

378373
Instead of permanently enabling SemanticDB in build.sbt, use the
379374
`scalafixEnable` command to enable SemanticDB the current active sbt shell
380-
session.
375+
session:
381376

382377
```
383378
> scalafixEnable
@@ -411,25 +406,35 @@ git diff // should produce a diff
411406
First, install the [Coursier](https://get-coursier.io/docs/cli-installation)
412407
command-line interface.
413408

414-
Then, download the Scalafix runner built with the latest version of Scala
415-
(@SCALA3NEXT@)
409+
Then, install or launch a Scalafix runner built with the latest version of Scala
410+
(@SCALA3NEXT@):
416411

417412
```sh
418413
cs install scalafix
419-
./scalafix --version # Should say @VERSION@
414+
scalafix --version # Should say @VERSION@
415+
416+
cs install scalafix:0.14.0
417+
scalafix --version # Should say 0.14.0
418+
419+
cs launch scalafix:0.13.0 -- --version # Should say 0.13.0
420420
```
421421

422422
> If you plan to use advanced semantic rules like `ExplicitResultTypes`, you
423423
> must use the version of Scalafix built with a Scala version matching your
424-
> target source files.
424+
> target source files (major.minor).
425425
>
426426
> If your target files are not built with the latest minor version of Scala,
427-
> use one of the following commands to create a custom runner
427+
> use one of the following commands to create a custom runner:
428428
>
429429
> ```sh
430430
> cs bootstrap ch.epfl.scala:scalafix-cli_@SCALA212@:@VERSION@ --main scalafix.cli.Cli -o scalafix_2.12
431431
> cs bootstrap ch.epfl.scala:scalafix-cli_@SCALA213@:@VERSION@ --main scalafix.cli.Cli -o scalafix_2.13
432-
> cs bootstrap ch.epfl.scala:scalafix-cli_@SCALA3LTS@:@VERSION@ --main scalafix.cli.Cli -o scalafix_3-lts
432+
> cs bootstrap ch.epfl.scala:scalafix-cli_@SCALA3LTS@:@VERSION@ --main scalafix.cli.Cli -o scalafix_3.3-lts
433+
> ```
434+
>
435+
> Alternatively, you can run a one-shot command:
436+
> ```sh
437+
> cs launch --scala X.Y scalafix -- --version
433438
> ```
434439
435440
### Help
@@ -453,7 +458,7 @@ Scalafix is supported in other build tools via externally maintained plugins:
453458
Our CI publishes a snapshot release to Sonatype on every merge into main. Each
454459
snapshot release has a unique version number, jars don't get overwritten.
455460

456-
If using the sbt plugin
461+
If using the sbt plugin:
457462

458463
```diff
459464
// project/plugins.sbt
@@ -462,7 +467,7 @@ If using the sbt plugin
462467
+dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "@NIGHTLY_VERSION@"
463468
```
464469

465-
If using the command-line interface
470+
If using the command-line interface:
466471

467472
```sh
468473
cs launch ch.epfl.scala:scalafix-cli_@SCALA213@:@NIGHTLY_VERSION@ -r sonatype:snapshots --main scalafix.cli.Cli -- --help

0 commit comments

Comments
 (0)