scalafix

Refactoring and linting tool for Scala

BSD-3-CLAUSE License

Stars
801

Bot releases are hidden (Show)

scalafix - v0.9.23

Published by mlachkar almost 4 years ago

Pull Requests

  • revert unnecessary breaking change in testkit (#1275) @bjaglin
  • scalafmt-core 2.7.5 (#1274) @bjaglin
  • CI cleanup (#1136) @bjaglin
  • Kill and make sure that the presentation compiler is interrupted befo… (#1272) @mlachkar
  • add --triggered flag to load overlay section in .scalafix.conf (#1217) @taisukeoe
  • Update mdoc, sbt-mdoc to 2.2.10 (#1270) @scala-steward
  • Update scalacheck to 1.15.0 (#1269) @scala-steward
  • Update sbt to 1.4.1 (#1268) @scala-steward
  • Update interface to 1.0.1 (#1267) @scala-steward
  • Update sbt-mima-plugin to 0.8.1 (#1266) @scala-steward
  • Update organize-imports to 0.4.3 (#1265) @scala-steward
  • Replace travis workflow by a github action (#1263) @mlachkar
  • enable scalafix plugin on scalafix-testkit (#1262) @mlachkar
  • add a new method to Patch Api (#1260) @mlachkar
  • Add a message error to scalafixFileEvaluation (#1251) @mlachkar
  • Respect the intent of rules authors when returning atomic patches (#1261) @mlachkar
  • Update scalameta, semanticdb-scalac-core, ... to 4.3.24 (#1258) @scala-steward
  • check the whole caret position in the testkit (#1259) @gontard
  • Update sbt to 1.4.0 (#1257) @scala-steward
  • Update organize-imports to 0.4.2 (#1256) @scala-steward
  • Fix warn messages in doc (#1255) @mlachkar
  • Activate scalafix on unit project (#1253) @mlachkar
  • Enable scalafix plugin (#1218) @mlachkar
  • Update sbt-buildinfo to 0.10.0 (#1226) @scala-steward
  • Update sbt-mdoc to 2.2.9 (#1249) @scala-steward
  • Goodbye from Marcelo Cenerino (#1248) @marcelocenerine
scalafix - Scalafix v0.9.12

Published by olafurpg over 4 years ago

  • #1070 Use None and Nil instead or Option.empty[T] and List.empty[T] when inserting explicit result types for Option[T] and List[T]
  • #1079 Add support for Scala 2.12.11
scalafix - Scalafix v0.9.7

Published by olafurpg about 5 years ago

  • #980 Upgrade to Scala 2.12.10
  • #981 Expose all synthetic trees, by @ingarabr
scalafix - Scalafix v0.9.6

Published by olafurpg about 5 years ago

  • #979 Fix issue with handling of source files with spaces in their names, by @jameskoch.
  • New support for Scala 2.12.9
scalafix - Scalafix v0.9.5

Published by olafurpg over 5 years ago

Upgrade to Scalameta v4.1.9.

scalafix - Scalafix v0.9.3

Published by olafurpg over 5 years ago

  • #936 Add universal inequality check, by @Jacoby6000
  • #924 Add beforeStart and afterComplete methods on Rule, by @rorygraves
  • #922 Fix --auto-classpath bug, by @NicolasRouquette
  • #923 Remove Importee.Rename if it does not shadow anything, by @marcelocenerine
scalafix - Scalafix v0.9.4

Published by olafurpg over 5 years ago

  • #943 Upgrade to Scala v2.12.8 and Scalameta v4.1.4
scalafix - Scalafix v0.9.2

Published by olafurpg over 5 years ago

  • #930
scalafix - Scalafix v0.9.1

Published by olafurpg almost 6 years ago

We are happy to announce the release of Scalafix v0.9.1. Scalafix is a refactoring and linting tool for Scala.

Better performance

Running Scalafix on large codebases can be up to 2x faster now. A benchmark running Scalafix on the Spark codebase (3.201 files; 103.181 lines) previously took ~50 seconds now takes ~25 seconds. For more details see https://github.com/scalacenter/scalafix/pull/898. Big thanks to @marcelocenerine for this contribution!

Advanced regex disable

From #907

  1. Now error messages will underline the whole area of matched regex
  2. The relevant capture group can be specified, in case you have complicated regex's which may match on parts which aren't helpful in the error message
  3. scalafix errors which came from a regex match have access to the capture groups for substitution in the error messages.

Big thanks to @Jacoby6000 for this contribution!

Java 11

Scalafix now runs on Java 11. Our CI additionally runs the full build on Java 11 for every PR to prevent regressions.

Run published rules directly from the shell

Previously, you needed to declare scalafixDependencies in build.sbt to run published rules.

// before: build.sbt
scalafixDependencies in ThisBuild += "org.http4s" %% "http4s-scalafix" % "0.20.0-M3"

Now it's possible to run published rules directly from the sbt shell without updating build.sbt

> scalafix dependency:Http4s018To029@org.http4s:http4s-scalafix:0.20.0-M3

Custom resolvers for published rules

Previously, sbt-scalafix required published custom rules to be available on Maven Central. Now it's possible to publish custom rules anywhere (for example Bintray) and resolve them by updating scalafixResolvers in build.sbt. Big thanks to @kamilkloch for implementing this feature

Disable while loops

The new option DisableSyntax.noWhileLoops=true will trigger Scalafix to error on the usage of while loops.

Improved error messages

PR https://github.com/scalacenter/scalafix/pull/910 improved the reported messages for unexpected errors. Thanks to @raboof for reporting!

Contributors

$ git shortlog -sn --no-merges v0.9.0..v0.9.1
Jacob Barber
Ólafur Páll Geirsson
Kamil Kloch
Marcelo Cenerino
scalafix - Scalafix v0.9.0

Published by olafurpg about 6 years ago

We are excited to announce the release of Scalafix v0.9.0. Scalafix is a refactoring and linting tool for Scala.

This release includes improvements to documentation, the sbt plugin, better semantic APIs, improved support for custom rules and more.

This release has been under development since January 2018 and includes contributions from 19 contributors. Big thanks to everybody who made it possible!

Documentation 📖

Scalafix has a new website https://scalacenter.github.io/scalafix/

Scalameta v4.0 🔥

The Scalameta dependency has been upgraded to the newly released v4.0.0

New Semantic API 🧙

Semantic rules can now perform more advanced code analysis thanks to improvements in the semantic API:

  • Rules can look up symbol information for any symbol on the classpath, including dependencies. Previously, Scalafix only supported looking up information about symbols that were defined in the project.
  • The SymbolInformation data structure (previously named Denotation) now includes richer information about the symbol's signature, annotations and visibility access.
  • Rules can inspect the SemanticType, which is a sealed data structure describing the type of variables and parameters. Previously, value signatures were represented as strings making them difficult to analyze.
  • Rules can inspect SemanticTree, which is a sealed data structure describing synthetic code that is generated by the compiler from inferred type parameters, implicit arguments, implicit conversions and for comprehensions. Previously, synthetics were encoded as strings making them difficult to analyze.

The new Scalafix semantic API was made possible thanks to recent improvements in SemanticDB.

Improved sbt plugin 🛠

The sbt plugin has been overhauled to address issues with the previous plugin that were reported by our users. The new sbt plugin integrates directly with Scalafix library APIs resulting in an overall more polished user experience.

  • The old scalafix, scalafixTest and scalafixCli tasks have been merged into a single task: scalafix.
    • scalafixTest is now scalafix --check
    • scalafix continues to work as before
    • scalafixCli is no longer needed since scalafix accepts cli flags
  • New scalafixDependencies setting key to install custom rules from Maven Central.
  • Common build mis-configuration such as missing compiler options are reported by Scalafix before compilation starts helping users detect problems as soon as possible.
  • Syntactic rules no longer trigger compilation significantly speeding up usage if you only use syntactic rules.

Check out the installation instructions to learn more how to use the sbt plugin.

Performance 🚀

This release improves the performance of the Scalafix command-line interface and the sbt plugin. A user reported speedups from 65 minutes down to to 2 minutes when running rewrites on a large codebase after upgrading from the previous release.

New build tools API 🔧

There is now an official public API to programmatically invoke Scalafix from build tools or IDEs. The API is available in the module scalafix-interfaces and it's written in Java with zero dependencies weighing a total of 12kb. The API is designed to have a stable binary interface across future releases of Scalafix. This API is used by the new sbt plugin, and is available to users who would like to integrate Scalafix with other build tools like Maven, Gradle.

To learn more about the build tools API, consult the scalafix-interfaces Javadocs.

Breaking changes ⚠️

For end users

  • The v0.5.x API for rules has moved from the scalafix package into scalafix.v0. The scalafix.v0 package will be removed when Scalafix v1.0 is released in the future.
  • The rules Disable and MissingFinal have moved to a separate project https://github.com/vovapolu/scaluzzi
  • The rule ExplicitResultTypes has been removed since it produced incorrect code.
  • The rules DottyKeywords, DottyVarArgPattern and DottyVolatileLazyVal have been removed. Scala 3 migration rewrites will be published as a separate project so that they can evolve at a different pace than the Scalafix core APIs.
  • The sbtfix task in the sbt plugin has been removed, use scalafix --files build.sbt --files project instead.

For tooling integrations

  • The command-line interface requires the --classpath argument to include a full classpath, including dependencies. Dependencies do not have to be compiled with the SemanticDB compiler plugin but sources that Scalafix should analyze must be compiled with SemanticDB.
  • The command-line interface has a new --scalac-options flag to document what compiler options were used to compile the sources. This is required by rules like RemoveUnused to validate the -Ywarn-unused-import is enabled and in the future also to ensure that Scalafix respects SemanticDB options like -P:semanticdb:targetroot and -P:semanticdb:exclude.

For rule authors

Before Now
import scalafix._ import scalafix.v0._
import org.langmeta._ import scala.meta._
import scala.meta.Database import scalafix.v0.Database
import scala.meta.Document import scalafix.v0.Document
import scala.meta.Symbol import scalafix.v0.Symbol
import scala.meta.Denotation import scalafix.v0.Denotation
import scala.meta.ResolvedName import scalafix.v0.ResolvedName
import scala.meta.ResolvedSymbol import scalafix.v0.ResolvedSymbol
import scala.meta.Synthetic import scalafix.v0.Synthetic

It is recommended to migrate rules to use the new scalafix.v1 API, which imposes further changes from scalafix.v0:

object MyRule extends v0.Rule("MyRule")
class MyRule extends v1.SyntacticRule("MyRule")
case class MyRule(index: SemanticdbIndex) extends v0.SemanticRule(index, "MyRule")
class MyRule extends v1.SemanticRule("MyRule")
override def init(conf: metaconfig.Conf): Configured[v0.Rule]
override def withConfiguration(conf: scalafix.v1.Configuration): Configured[v1.Rule]
override def fix(ctx: v0.RuleCtx): Patch
// for syntactic rules
override def fix(implicit doc: v1.SyntacticDoc): Patch
// for semantic rules
override def fix(implicit doc: v1.SemanticDoc): Patch
// Patch operations where `ctx: v0.RuleCtx`
ctx.addRight()
ctx.replaceTree()
ctx.removeImportee()
Patch.addRight()
Patch.replaceTree()
Patch.removeImportee()

Additionally, v1 rules are now loaded using JDK ServiceLoader. To make a custom rule discoverable to Scalafix, create a resource file META-INF/services/scalafix.v1.Rule with the fully qualified name of your rule

// resource file META-INF/services/scalafix.v1.Rule
fully.qualified.MyRule

Contributors ❤️

Big thanks to all 19 contributors who made this release possible

$ git shortlog -sn --no-merges v0.5.10..HEAD
Ólafur Páll Geirsson
vovapolu
Marcelo Cenerino
Guillaume Massé
tanishiking24
Sam Halliday
Eugene Burmako
Shane Delmore
Sean Sullivan
Piotr Galar
Sergii Kyryliuk
Øyvind Raddum Berg
Jimin Hsieh
Per Øyvind Kanestrøm
nicodelpiano
Joan Goyeau
Gabriele Petronella
Eugene Yokota
Andrew Valencik
scalafix - Scalafix v0.9.0-RC1

Published by olafurpg about 6 years ago

It's barely been 24 hours since Scalafix https://github.com/scalacenter/scalafix/releases/tag/v0.8.0-RC1 release but a lot has happened since then :)

Feature improvements

Rule authors

scalafix-noinfer

wrote 'stricter Scala with -Xlint, -Xfatal-warnings, and Scalafix'. I am so excited about the Scalafix 0.8.0-RC1 that came out today that I wrote a custom Scalafix rule scalafix-noinfer. #scala http://eed3si9n.com/stricter-scala-with-xlint-xfatal-warnings-and-scalafix

Breaking changes

This release bumps the minor version since the signature of scalafix.v1.IdTree has changed

// before
case class IdTree(symbol: Symbol)
// now
case class IdTree(info: SymbolInfo) { def symbol = info.symbol }

Big thanks to everybody who reported issues and contributed to this release!

scalafix - Scalafix v0.8.0-RC1

Published by olafurpg about 6 years ago

We are excited to announce the release of Scalafix v0.8.0. Scalafix is a refactoring and linting tool for Scala.

This release includes improvements to documentation, the sbt plugin, better semantic APIs, improved support for custom rules and more.

This release has been under development since January 2018 and includes contributions from 19 contributors. Big thanks to everybody who made it possible!

Documentation 📖

Scalafix has a new website https://scalacenter.github.io/scalafix/

Scalameta v4.0 🔥

The Scalameta dependency has been upgraded to the newly released v4.0.0

New Semantic API 🧙

Semantic rules can now perform more advanced code analysis thanks to improvements in the semantic API:

  • Rules can look up symbol information for any symbol on the classpath, including dependencies. Previously, Scalafix only supported looking up information about symbols that were defined in the project.
  • The SymbolInformation data structure (previously named Denotation) now includes richer information about the symbol's signature, annotations and visibility access.
  • Rules can inspect the SemanticType, which is a sealed data structure describing the type of variables and parameters. Previously, value signatures were represented as strings making them difficult to analyze.
  • Rules can inspect SemanticTree, which is a sealed data structure describing synthetic code that is generated by the compiler from inferred type parameters, implicit arguments, implicit conversions and for comprehensions. Previously, synthetics were encoded as strings making them difficult to analyze.

The new Scalafix semantic API was made possible thanks to recent improvements in SemanticDB.

Improved sbt plugin 🛠

The sbt plugin has been overhauled to address issues with the previous plugin that were reported by our users. The new sbt plugin integrates directly with Scalafix library APIs resulting in an overall more polished user experience.

  • The old scalafix, scalafixTest and scalafixCli tasks have been merged into a single task: scalafix.
    • scalafixTest is now scalafix --check
    • scalafix continues to work as before
    • scalafixCli is no longer needed since scalafix accepts cli flags
  • New scalafixDependencies setting key to install custom rules from Maven Central.
  • Common build mis-configuration such as missing compiler options are reported by Scalafix before compilation starts helping users detect problems as soon as possible.
  • Syntactic rules no longer trigger compilation significantly speeding up usage if you only use syntactic rules.

Check out the installation instructions to learn more how to use the sbt plugin.

Performance 🚀

This release improves the performance of the Scalafix command-line interface and the sbt plugin. A user reported speedups from 65 minutes down to to 2 minutes when running rewrites on a large codebase after upgrading from the previous release.

New build tools API 🔧

There is now an official public API to programmatically invoke Scalafix from build tools or IDEs. The API is available in the module scalafix-interfaces and it's written in Java with zero dependencies weighing a total of 12kb. The API is designed to have a stable binary interface across future releases of Scalafix. This API is used by the new sbt plugin, and is available to users who would like to integrate Scalafix with other build tools like Maven, Gradle.

To learn more about the build tools API, consult the scalafix-interfaces Javadocs.

Breaking changes ⚠️

For end users

  • The v0.5.x API for rules has moved from the scalafix package into scalafix.v0. The scalafix.v0 package will be removed when Scalafix v1.0 is released in the future.
  • The rules Disable and MissingFinal have moved to a separate project https://github.com/vovapolu/scaluzzi
  • The rule ExplicitResultTypes has been removed since it produced incorrect code.
  • The rules DottyKeywords, DottyVarArgPattern and DottyVolatileLazyVal have been removed. Scala 3 migration rewrites will be published as a separate project so that they can evolve at a different pace than the Scalafix core APIs.
  • The sbtfix task in the sbt plugin has been removed, use scalafix --files build.sbt --files project instead.

For tooling integrations

  • The command-line interface requires the --classpath argument to include a full classpath, including dependencies. Dependencies do not have to be compiled with the SemanticDB compiler plugin but sources that Scalafix should analyze must be compiled with SemanticDB.
  • The command-line interface has a new --scalac-options flag to document what compiler options were used to compile the sources. This is required by rules like RemoveUnused to validate the -Ywarn-unused-import is enabled and in the future also to ensure that Scalafix respects SemanticDB options like -P:semanticdb:targetroot and -P:semanticdb:exclude.

For rule authors

Before Now
import scalafix._ import scalafix.v0._
import org.langmeta._ import scala.meta._
import scala.meta.Database import scalafix.v0.Database
import scala.meta.Document import scalafix.v0.Document
import scala.meta.Symbol import scalafix.v0.Symbol
import scala.meta.Denotation import scalafix.v0.Denotation
import scala.meta.ResolvedName import scalafix.v0.ResolvedName
import scala.meta.ResolvedSymbol import scalafix.v0.ResolvedSymbol
import scala.meta.Synthetic import scalafix.v0.Synthetic

It is recommended to migrate rules to use the new scalafix.v1 API, which imposes further changes from scalafix.v0:

object MyRule extends v0.Rule("MyRule")
class MyRule extends v1.SyntacticRule("MyRule")
case class MyRule(index: SemanticdbIndex) extends v0.SemanticRule(index, "MyRule")
class MyRule extends v1.SemanticRule("MyRule")
override def init(conf: metaconfig.Conf): Configured[v0.Rule]
override def withConfiguration(conf: scalafix.v1.Configuration): Configured[v1.Rule]
override def fix(ctx: v0.RuleCtx): Patch
// for syntactic rules
override def fix(implicit doc: v1.SyntacticDoc): Patch
// for semantic rules
override def fix(implicit doc: v1.SemanticDoc): Patch
// Patch operations where `ctx: v0.RuleCtx`
ctx.addRight()
ctx.replaceTree()
ctx.removeImportee()
Patch.addRight()
Patch.replaceTree()
Patch.removeImportee()

Additionally, v1 rules are now loaded using JDK ServiceLoader. To make a custom rule discoverable to Scalafix, create a resource file META-INF/services/scalafix.v1.Rule with the fully qualified name of your rule

// resource file META-INF/services/scalafix.v1.Rule
fully.qualified.MyRule

Contributors ❤️

Big thanks to all 19 contributors who made this release possible

$ git shortlog -sn --no-merges v0.5.10..HEAD
Ólafur Páll Geirsson
vovapolu
Marcelo Cenerino
Guillaume Massé
tanishiking24
Sam Halliday
Eugene Burmako
Shane Delmore
Sean Sullivan
Piotr Galar
Sergii Kyryliuk
Øyvind Raddum Berg
Jimin Hsieh
Per Øyvind Kanestrøm
nicodelpiano
Joan Goyeau
Gabriele Petronella
Eugene Yokota
Andrew Valencik
scalafix - Scalafix v0.6.0-M16

Published by olafurpg about 6 years ago

⚠️ This is an unstable and undocumented milestone release intended only for early adopters. It's recommended to stay on v0.5.10 until v0.6.0 stable is out.

scalafix - Scalafix v4.0.0-M15

Published by olafurpg about 6 years ago

⚠️ This is an unstable and undocumented milestone release intended only for early adopters. It's recommended to stay on v0.5.10 until v0.6.0 stable is out.

scalafix - Scalafix v0.6.0-M14

Published by olafurpg about 6 years ago

⚠️ This is an unstable and undocumented milestone release intended only for early adopters. It's recommended to stay on v0.5.10 until v0.6.0 stable is out.

IMPORTANT. If you are on sbt 1.1 and can't upgrade to sbt v1.2.1 then the recommended version is 0.6.0-M14-3 to work around https://github.com/sbt/sbt/issues/4299 ClassCastException: sbt.internal.util.Init$SettingList.

  • #786 Upgrade to Scalameta v4.0.0-M8. This is likely one of the last milestone releases before Scalameta v4. At this time there are 5 remaining open tickets in the milestone for v4.0 https://github.com/scalameta/scalameta/milestone/26
  • #781 Support loading custom rules by their name instead of FQN. This allows custom rules to include a text file META-INF/services/scalafix.v1.Rule in resources with the FQN of the rule so that users can reference external rules by their name (for example NoVars) instead of the fully qualified class name (for example class:com.bar.NoVars).
  • #783 Add scalafix-interfaces with Java APIs for reflective invocation. This PR adds a Java module scalafix-interfaces that can be used by build tools and IDEs to invoke Scalafix using JVM reflection. The module is 8kb with no external dependencies, the documentation is available here: https://www.javadoc.io/doc/ch.epfl.scala/scalafix-interfaces/0.6.0-M14
  • https://github.com/scalacenter/sbt-scalafix/pull/9 support scalafixDependencies: List[ModuleID] setting in sbt-scalafix to run external custom rewrites that are published to Maven. This feature is required for the upcoming Scala collection migration rewrites.
  • https://github.com/scalacenter/sbt-scalafix/pull/8 add back sbt 0.13 support to sbt-scalafix. The last M12 release only supported sbt 0.13.
scalafix - Scalafix v0.6.0-M12

Published by olafurpg about 6 years ago

NOTE. This milestone release is unstable, it is recommended to stay on v0.5.10 until all of the tickets in scalameta/scalameta/milestone/26 have been fixed.

Rule authors

The Scalameta dependency has been updated to v4.0.0-M6, see release notes.

There is a best-effort automatic rewrite to upgrade scalafix.g8 generated builds from v0.5. Full instructions are available here.

If you use SymbolMatcher.exact, make sure to update hardcoded symbols to use the new format

  • package symbols now use slash / instead of dot .
    • Before: scala.collection.immutable.List#
    • Now: scala/collection/immutable/List#
  • val symbols now use dot . without ()
    • Before: scala.package.Either().
    • Now: scala/package.Either.

Users

Please wait until v0.6 stable is out and the website has been updated to document the latest improvements.

scalafix - Scalafix v0.6.0-M11

Published by olafurpg over 6 years ago

NOTE. This milestone release is unstable, it is recommended to stay on v0.5.10 until all of the tickets in https://github.com/scalameta/scalameta/milestone/26 have been fixed.

  • upgrade to Scalameta v4.0.0-M4, #756
  • the sbt plugin has been moved to a separate repository https://github.com/scalacenter/sbt-scalafix.
  • the sbt plugin will temporarily only work for sbt 1.0. Support for 0.13 will be re-instated before v0.6 final.
  • the sbt plugin no longer dynamically resolves and classloads scalafix artifacts, it's a "normal plugin" now.
scalafix - Scalafix v0.6.0-M9

Published by olafurpg over 6 years ago

  • #750 by @olafurpg, add scalafix.cli.Cli back
scalafix - Scalafix v0.6.0-M2

Published by olafurpg over 6 years ago

NOTE. v0.6.0-M3 has been released with minor fixes.

This is the second milestone release for v0.6 that includes more architectural change in how semantic rewrites work.

⚠️ This release is still not intended for public usage yet, there are several known regressions that need to be addressed before releasing v0.6.0 stable. ⚠️

Highlights

Automatically suppress linter errors with scalafixAutoSuppressLinterErrors

Contributed by @vovapolu, funded by Scalafix Bountysource. It is difficult to introduce new linter rules into existing large codebases. Scalafix already supports the --diff and --diff-base=master options to run linters on a subset of the codebase. This feature enables users to automatically insert /* scalafix:ok */ comments next to linter violations.

// before
var x = null // ERROR, null is disallowed!

// after running scalafixAutoSuppressLinterErrors
var x = null/* scalafix:ok */ // OK, error suppressed by comment

By inserting the comment in the codebase, your team may be extra motivated to fix suppressed errors.

Disable symbol by regex

Contributed by @vovapolu, funded by Scalafix Bountysource. Previously, it was only possible to disable individual symbols with the Disable rule. Now it is possible to disable a group of symbols matching a given regex. In .scalafix.conf, configure

Disable.symbols = [
  {
    regex = {
      includes = "scala.collection.mutable.*"
      excludes = "scala.collection.mutable.ArrayBuffer"
    }
    message = "Use immutable data structures"
  }
]

This configuration will report errors on all usages of symbols from the scala.collection.mutable package excluding ArrayBuffer.

Respect @SuppressWarnings to disable rules

Contributed by @marcelocenerine. In addition to /* scalafix:off */ comments, it's now possible to suppress linter errors with @SuppressWarnings("scalafix:NoNulls") annotations. Annotations are enabled across the range of the definition they annotate.

@SuppressWarnings("scalafix:NoNulls")
def dirtyBusiness(): Unit = {
    var x = null // OK, because NoNulls rule is disabled
    ...
}
// NoNulls rule is re-enabled after dirtyBusiness() definition
var x = null // error, nulls are disabled

When mixed with /* scalafix:off */ comments, annotations take precedence.

Tab completions show rule descriptions

Contributed by @tanishiking. Now it's possible to read brief descriptions for rules when using tab completion in both sbt and zsh.

scalafix-zsh-completion

Upgrade to SemanticDB v3.7

Contributed by @olafurpg and @xeno-by, relevant for rule authors. This is the first step towards making it possible for rules to lookup full type signatures of Java and Scala signatures from the classpath of a program. This functionality is enabled thanks to

  • a comprehensive spec covering details of how Scala and Java signatures map to SemanticDB Type
  • new metacp library and command-line tool to extract SemanticDB type signatures from a classpath
  • updates to semanticdb-scalac compiler plugin to emit new type signatures

This is the result of a multiple month effort and will open many exciting use-cases for rule authors in the future, including

  • robust organize imports refactoring
  • scope-aware pretty printing
  • class hierarchy aware linting

Breaking changes

  • sbt-scalafix no longer automatically installs the semanticdb-scalac compiler plugin. This means you need to manually add the following snippet of code in your build.sbt for all projects.
addCompilerPlugin(semanticdbScalac)
scalacOptions += "-Yrangepos"
  • Code that was deprecated in v0.5.x has been removed
  • sbtfix and sbtfixTest no longer support running semantic rules. It's now only possible to run syntactic rules on *.sbt files.

Summary of pull requests

The following list is a summary of the activity since the last milestone release.

End user facing

  • #496 by olafurpg, sbt-scalafix now respects unmangedSources.in(scalafix)
  • #587 by vovapolu, make sbt-scalafix follow conventions around sbt configurations
  • #589 by olafurpg, sbt-scalafix no longer automatically instals semanticdb-scalac compiler plugin
  • #601 #669 by vovapolu, new configuration options for Disable rule
  • #611 by tanishiking, fix invalid rewrite for ProcedureSyntax
  • #616 by eed3si9n, fix bug in ProcedureSyntax rule for type params
  • #620 by marcelocenerine, Respect @SuppressWarnings to disable rules
  • #639 by tanishiking, add completion for rules description in zsh.
  • #642 by tanishiking, add completion for rules description in sbt.
  • #645 by olafurpg, sbtfix task no longer supports semantic rewriting, only syntactic
  • #646 by vovapolu, add --auto-suppress-linter-errors in cli and scalafixAutoSuppressLinterErrors task in sbt-scalafix to automatically insert /* scalafix:ok */ to suppress linter violations
  • #669 by vovapolu, add support to disable symbol via regex

Docs

  • #637 by ShaneDelmore, add link to pants scalafix usage instructions in docs
  • #667 by jiminhsieh, fix invalid scalacOption in docs.
  • #671 by jiminhsieh, fix typo in docs
  • #644 by olafurpg, remove sbtfix and semanticdb-sbt from the installation docs.
  • #654 by valencik, fix vertical alignment of comments in docs
  • #657 by tanishiking, fix typo in README

Rule author facing

  • #474 by marcelocenerine, add methods for dealing with whitespaces in patch API
  • #534 by marcelocenerine, make 'from' parameter in TokenList.slice/find inclusive

Internal

  • #509 by olafurpg, bootstrap: use scalafix in scalafix build
  • #585 by MasseGuillaume, add AppVeyor as a CI on Windows
  • #590 by olafurpg, remove deprecated APIs from v0.5.0 release
  • #595 by xeno-by, upgrade to Scalameta 3.0.0
  • #602 by xeno-by, upgrade to Scalameta 3.2.0
  • #615 by xeno-by, upgrade to Scalameta 3.3.1
  • #615 by xeno-by, upgrade to Scalameta 3.3.1
  • #618 by olafurpg, simplify ProcedureSyntax implementation
  • #633 #631 #630 by sullis, upgrade build dependencies
  • #675 by olafurpg, upgrade to scalameta 3.7.0 with default settings.
  • #677 by olafurpg, Upgrade to Scalameta v3.7.3

Thank you!

Big thanks to 11 contributors for making this release happen!

$ git shortlog -sn --no-merges v0.6.0-M1..v0.6.0-M2
    37	vovapolu
    22	Ólafur Páll Geirsson
    18	Marcelo Cenerino
     6	tanishiking24
     3	Sean Sullivan
     2	Jimin Hsieh
     2	Eugene Burmako
     1	Sam Halliday
     1	Eugene Yokota
     1	Andrew Valencik
     1	Shane Delmore
scalafix - Scalafix v0.6.0-M1

Published by olafurpg over 6 years ago

NOTE. We recommend to stay on 0.5.10 for at least a couple more milestone releases. This milestone release is primarily intended for downstream tooling to catch up to latest changes in Scalameta v3.

This release includes the following breaking changes

We plan to release at least one more milestone release that will do more breaking changes in sbt-scalafix related to installation. We are aiming for 0 breaking changes in the rewrite/lint API.