Scalafix v0.5.0-RC3
New features for end-users
This release introduces major improvements to sbt-scalafix, scalafix-cli.
sbtfix
task in sbt-scalafix to run rules on build sources.- Sbt1 rule to migrate usage of deprecated sbt 0.13 APIs, by @jvican.
- NoInfer linter that reports errors when the compiler reports types such as
Any
- ExplicitResultTypes experimental
unsafeShortenNames
option to insert imports instead of fully qualified names. - Scala.js support for scalafix-core, by @gabro.
- Configurable ExplicitResultTypes, by @taisuke.
- Configurable lint reporting.
- sbt-scalafix rule tab completion.
- scalafix-cli
--zsh
and--bash
to generate tab completion scripts for zsh and bash. - replace: to run quick one-off refactorings.
New features for rule authors
- Ability to implement rules for sources of sbt builds, including
*.sbt
files. The API to write sbt rules is identical to regular Scala rules. - Rules can now emit lint messages with
ctx.lint
, see LintMessage. - Thanks to upstream improvements in the Scalameta v2.0 Semantic API, it is now possible to
- query symbols of implicit arguments, implicit conversions, type parameters,
.apply
/.unapply
and symbol signatures. This represents significant portion of the work for Scalafix v0.5 and is a major milestone for the Scalameta semantic API. - parse symbols signatures as
scala.meta.Type
, including the newType.Method
which is the "type of methods" and cannot be written in source.
- query symbols of implicit arguments, implicit conversions, type parameters,
Rule.init(config): Configured[Rule]
allows rules to load the user configuration during rule construction. Before, rules had to parse the configuration while fixing each individual file.PatchOps.replaceSymbol/replaceTree
, see Patch.- PatchOps now has docstrings!
- Rules can have multiple names with optional deprecation warnings.
Bug fixes / Improvements
- ExplicitResultTypes produces valid type signatures in a lot more cases than before. Note that it still has some known bugs, see #324.
- More robust classloading to invoke scalafix in sbt-scalafix. Previously, sbt-scalafix used synthetic projects which cause problem in some multi-module builds. Now, sbt-scalafix uses Coursier instead.
- Improved dynamic compilation of custom rules while running from multi-module sbt builds.
- Extension methods now resolve to the correct symbol. For example,
head
inArray[Int].head
previously resolved toPredef.intArrayOps
and now it resolves toIndexedSeqOptimized.head
. - scalafix-cli automatically infers whether passed --rewrites are semantic or syntactic. This means it's possible to run custom syntactic rules from scalafix-cli without passing in
--classpath
.
Breaking changes
From 0.5 onwards, our CI will check binary breaking changes in the public API on every pull request. Note that modules inside the package scalafix.internal
don't promise binary compatibility between any releases, including PATCH upgrades.
-
github:
rewrites should be inside thescalafix/rules/...
directory instead ofscalafix/rewrites/...
directory -
scalafix.Rewrite/SemanticRewrite
is now deprecated andMirror
is nowSemanticdbIndex
.// before case class MyRewrite(mirror: Mirror) extends SemanticRewrite(mirror) { def rewrite(ctx: RewriteCtx): Patch } // before case class MyRule(index: SemanticdbIndex) extends SemanticRule(index) { def fix(ctx: RewriteCtx): Patch }
-
scalafix.testkit.SemanticRewriteSuite
is now nowSemanticRuleSuite
. -
scalafix.config
has been moved toscalafix.internal.config
. Configuration case classes break binary compatility with every new field. -
.symbol
now returnsOption[Symbol]
instead ofSymbol
..symbolOpt
has been deprecated. -
A large number of unused methods and classes inside
scalafix.internal.util.Failure
,scalafix.`package`
andscalafix.syntax
has been removed. -
upgraded to Scalameta 2.0, which has several breaking changes in the Tree api.
-
The
VolatileLazyVal
rule is now named DottyVolatileLazyVal.
Contributors
git shortlog -sn --no-merges v0.4.2..v0.5.0-RC3
shows 5 people contributed to this release.
- Ólafur Páll Geirsson
- Gabriele Petronella
- Guillaume Massé
- Taisuke Oe
- Andy Scott