VirtusLab / scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
https://scala-cli.virtuslab.org
Apache License 2.0
546 stars 128 forks source link

scalafix command to run library migration & hygiene rules #647

Open bjaglin opened 2 years ago

bjaglin commented 2 years ago

Is your feature request related to a problem? Please describe.

Scalafix provides a CLI which is rather easy to use to run syntactic rules (using on-demand scalameta parsers under the hood, like scalafmt) but is a hassle to setup to run semantic rules (requiring prior compilation output, namely class & semanticdb files). That's why we usually recommend using build tools plugins instead (either the official sbt plugin or the community-driven maven, gradle & mill plugins).

For projects managed by Scala CLI, using the Scalafix CLI is currently the only option. Providing a built-in integration with Scalafix inside Scala CLI would be useful to cover the typical Scalafix use cases on such projects:

  1. helping library clients to handle deprecation and breaking changes ("migration" use-case)
  2. enforcing conventions and preventing bad smells ("hygiene" use-case)

Describe the solution you'd like

A scalafix command could take care of

Additional context

If Scala CLI adoption picks up, I assume https://github.com/scala-steward-org/scala-steward will eventually support projects managed by Scala CLI and be able to update directives. A support for running Scalafix migrations just like in the other build tools would then be welcome, and could rely on that built-in scalafix command.

Automating the bump of dependencies by updating directives might be implemented as part of Scala CLI itself in the future, but in any case integrating Scalafix (potentially without a user-facing command) will be useful to leverage existing migration rules.

bjaglin commented 2 years ago

cc @olafurpg @mlachkar

romanowski commented 2 years ago

Thank you @bjaglin for opening the issue. We have got an issue open for adding support for scalafix for quite a while (see #15) but yours has much better motivation so I am going to close the old one as a duplicate.

Vigorge commented 4 months ago

Hello, I'm interested in this question and have been working on an option for this improvement for some time. Now I can see some progress in my project and I plan to create a PR in the near future.

tgodzik commented 4 months ago

Sure! Do let us know if you need any help.

arturopala commented 3 months ago

Hello, any idea if this will ever come?

bishabosha commented 3 months ago

Hello, any idea if this will ever come?

its in this PR https://github.com/VirtusLab/scala-cli/pull/2968