Skip to content

sbt: scalafixConfig setting doesn't work #1033

Closed
scalacenter/sbt-scalafix
#103
@steinybot

Description

@steinybot

Setting the scalafixConfig setting in sbt does not work and causes mysterious errors.

The error you get is:

sbt:bug-reports> scalafix --check
error: The Scala compiler option "-Ywarn-unused" is required to use RemoveUnused.
To fix this problem, update your build to use at least one Scala compiler
option that starts with "-Ywarn-unused"
[error] (Compile / scalafix) scalafix.sbt.ScalafixFailed: CommandLineError
[error] Total time: 2 s, completed 13/12/2019 10:24:27 PM

And yet:

sbt:bug-reports> show scalacOptions
[info] * -Yrangepos
[info] * -Ywarn-unused
[success] Total time: 0 s, completed 13/12/2019 10:28:27 PM

There is a reproduction here https://github.com/steinybot/bug-reports/tree/scalafix/scalafixConfig-sbt.

I did a little debugging and there are some strange goings. The args look like they aren't getting set correctly at all. Something else that is noticeable is that scalafix.sbt.ScalafixPlugin#scalafixInputTask will use the default args to load the rules and check if it isSemantic which will be false and it will run scalafix.sbt.ScalafixPlugin#scalafixSyntactic. It doesn't even appear to use scalacOptions unless it runs scalafix.sbt.ScalafixPlugin#scalafixSemantic.

This is possibly related to #949.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions