Releases: scalacenter/scalafix
Scalafix v0.6.0-M2
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.
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.
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
andsbtfixTest
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 andscalafixAutoSuppressLinterErrors
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 v0.6.0-M1
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
- Upgrade to Scalameta v3.2.0. Requires a
clean;compile
to rebuild old SemanticDB payloads. - sbt-scalafix unscoped
scalafixCli
task only runs in main configuration, not test. To get the old behavior,compile:scalafixCli ; test:scalafixCli
. scalafixConfigure(Compile, Test, IntegrationTest)
has been replaced withinConfig(IntegrationTest)(scalafixConfigSettings)
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.
Scalafix v0.5.10
v0.5.10
Previous release note: v0.5.8 / v0.5.9
This is a big release for scalafix: (7 Dec 2017 - 26 Jan 2018)
- two new contributors: @LeonardMeyer and @marcelocenerine, welcome!
- 34 merged PR & closed issues: https://github.com/scalacenter/scalafix/milestone/9?closed=1
- @vovapolu's work is sponsored by https://salt.bountysource.com/teams/scalafix/supporters
Users
Rules
- #548 New Rule: MissingFinal @vovapolu
- #553 New Rule: LeakingImplicitClassVal @LeonardMeyer
- #515 #563 #546 New Rule: DisableUnless @vovapolu
- #494 #561 #533 #548 #546 Add Rule configuration: DisableSyntax @vovapolu @MasseGuillaume
Docs
- Overview of all rules is easier to read now https://scalacenter.github.io/scalafix/docs/users/rules
- Configuration options for all rules are now documented with a description, default values and example values. See https://scalacenter.github.io/scalafix/docs/rules/ExplicitResultTypes
Honorable mention
Did not make it due to blocking issues:
- #513 #522 #556 New Rule: DottyAutoTuplingFunctionArgs @marcelocenerine @olafurpg
- #554 New Rule: DiscardedValues @vovapolu
Features
- #538 #540 We now publish SNAPSHOT artifacts on merge. @olafurpg
Read: https://scalacenter.github.io/scalafix/docs/users/installation#snapshot - #520 New scalafixCli sbt task with tab completion. @MasseGuillaume
- #511 Add --diff for rewrites. It's now possible to do rewrite on a git diff. @MasseGuillaume
- #503 Add escape mechanism (// scalafix:ok) for rules with rewrites (Patch) @MasseGuillaume
Bugfixes
- #562 Fix bug in ExplicitResultTypes. @olafurpg
- #497 Fix bug in DisableSyntax position. @olafurpg
- #544 Use lenient dialect in scalafix-reflect. @olafurpg
- #537 Remove trailing comma in Multi-line imports. @olafurpg
- #490 Use unmanagedSources instead of unmanagedSourceDirectories. @olafurpg
Rule Authors
- #474 #539 Add TokenList.{leadingSpaces, trailingSpaces} @marcelocenerine @olafurpg
- #534 Make 'from' parameter in TokenList.slice/find inclusive @marcelocenerine
- #500 Add CustomMessage to the public api @MasseGuillaume
Scalafix Developers
- #514 We enabled scalafix in scalafix! Run the scalafix task to make the CI happy! @olafurpg
- #565 Upgrade to metaconfig v0.6 @olafurpg
- #565 Upgrade to metaconfig v0.6.Enabling automatic derivation for configuration decoders and documentation generation. (Example: https://scalacenter.github.io/scalafix/docs/rules/ExplicitResultTypes) Read: https://olafurpg.github.io/metaconfig/#genericderivedecoder for more details. @olafurpg
Scalafix v0.5.9
Please use v0.5.10
Scalafix v0.5.8
Scalafix v0.5.7
- #472 Add --diff to only report linter messages from a
git diff
. Useful to enable Scalafix into an existing codebase. For more details, see --diff and --diff-base in --help .
Example usage, find all var
s that are introduced since scalafix v0.5.6
$ scalafix -r DisableSyntax --config-str="DisableSyntax.keywords=[var]" --diff-base=v0.5.6
scalafix-tests/unit/src/test/scala/scalafix/tests/cli/CliGitDiffTests.scala:224:13: error: [DisableSyntax.keywords.var] keywords.var is disabled
private var revision = 0
^
scalafix-core/shared/src/main/scala/scalafix/internal/util/IntervalSet.scala:31:11: error: [DisableSyntax.keywords.var] keywords.var is disabled
var i = start
^
- #467 Include column number in linter messages, by @olafurpg
- #469 Re-enable sbt 1.0 for sbt-scalafix, @olafurpg and @MasseGuillaume
- #486 Fix --diff-base hash resolution, by @MasseGuillaume
- #477 Upgrade to 2.12.4 from 2.12.3, by @olafurpg. While upgrading, we encountered a regression that resulted in an unresolved implicit due to the compiler swallowing a stack overflow error, see scala/bug#10649 for more details.
- #480 Fix false positives in testkit, by @MasseGuillaume
Scalafix v0.5.6
First of all, I am excited to welcome @MasseGuillaume to the Scalafix team! Moreover, I'm also thrilled to see @fommil joining the effort by sponsoring @vovapolu to work on improving scalafix for functional programming, see #451. Consider pitching in too!
Features
- #412 Make it easy to enable sbt-scalafix for custom configurations like
IntegrationTest withscalafixConfigure(Compile, Test, IntegrationTest)
, by @olafurpg. See https://scalacenter.github.io/scalafix/docs/users/installation#sbt-scalafix - #415 Suppress false linter errors with comments, by @MasseGuillaume. This PR makes
it a lot more practical to use Scalafix for linting, since previously there was no way
to silence Scalafix for exceptional cases where the linter reports a bogus
diagnostic. See https://scalacenter.github.io/scalafix/docs/users/configuration#per-source-file - #426 Upgrade to Scalameta v2.1.2, with support for Scala 2.11.12 and 2.12.4. Scala 2.11.11 and 2.12.3 are still supported, but no older Scala versions.
- #431 New
DisableSyntax
rule to disable keywords likereturn
/while
/throw
, by @MasseGuillaume - #444 Fix off-by-one error in
TokenList.next/prev
, by @ag91 and @GoldenZero - #445 skip local implicits in ExplicitResultTypes, by @erikwj
- #448 Add support for attaching custom messages to
Disable
rule, by @MasseGuillaume. See https://scalacenter.github.io/scalafix/docs/rules/Disable#custom-error-messages - #448 Add support for asserting against linter messages in
testkit
, by @MasseGuillaume. Example here. - #453 use a flexible parser dialect by default that, for example, supports trailing commas, by @olafurpg
Documentation
- #418 Add detailed documentation comparing scalafix with alternative tools
like Scala Refactoring, WartRemover, ScalaStyle and IntelliJ Scala plugin, by @olafurpg - #419 Simplify installation of sbt-scalafix with
scalafixEnable
command that can
automatically setup all the correct scala compiler settings from an sbt shell session, regardless of
existing settings in build.sbt. Previously, it was necessary to manually
update build.sbt with fairly tricky corner cases, by @olafurpg - #420 New section in the docs for using scalafix with Maven builds, https://scalacenter.github.io/scalafix/docs/users/installation#maven by @fanf
Internal
- #454 refactor the scalafix build for easier cross-building and cross-publishing, by @MasseGuillaume. Please note that there are no published artifacts for v0.5.4 and v0.5.5 due to the build misconfiguration that got fixed by this PR.
Scalafix v0.5.5
(redacted) There are no published artifacts for this release. Please use v0.5.6 https://github.com/scalacenter/scalafix/releases/tag/v0.5.6
Scalafix v0.5.4
(redacted) There are no published artifacts for this release. Please use v0.5.6 https://github.com/scalacenter/scalafix/releases/tag/v0.5.6
Scalafix v0.5.3
Bug fixes
- #378 Fix a bug in the implementation of
addLeft
, by @abeln - #382 Make
addGlobalImport
syntactic, by @olafurpg - #384 Handle coursier's --standalone classloader, by @xeno-by
- #388 Emit linter warnings from cli, by @olafurpg
Features and improvements
- #381 Add
resultType
extension method onSymbol
, by @gabro - #389 Remove dependency on scalamacros/paradise, by @olafurpg
- #386 New documentation website, by @gabro.
Check out our new website https://scalacenter.github.io/scalafix/
Every page has an "Edit this page" link at the top right, please send us PRs to improve the content.