Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better coordination between sbt-scalafmt & sbt-scalafix when scalaf..OnCompile := true #1206

Open
bjaglin opened this issue Jul 10, 2020 · 3 comments

Comments

@bjaglin
Copy link
Collaborator

bjaglin commented Jul 10, 2020

Expanding on @olafurpg 's idea:

  • sbt-scalafix would always execute callbacks registered in the task key scalafixHooks
  • when both scalafmtOnCompile := true &&scalafixOnCompile := true, sbt-scalafmt wouldn't run scalafmt before compile, but instead in scalafixHooks (which would be "fed" via a dynamic task)
@bjaglin bjaglin changed the title Better coordination between sbt-scalafmt & sbt-scalafix when scalafxxOnCompile Better coordination between sbt-scalafmt & sbt-scalafix when scalaf..OnCompile := true Jul 10, 2020
@bjaglin
Copy link
Collaborator Author

bjaglin commented Jul 10, 2020

/cc @poslegm - I can take the lead on that in the coming days

@bjaglin
Copy link
Collaborator Author

bjaglin commented Jul 10, 2020

Ideally we should first cut a release with the hooks to be able to write scripted tests with sbt-scalafix in sbt-scalafmt.

@bjaglin
Copy link
Collaborator Author

bjaglin commented Oct 6, 2020

In scalacenter/sbt-scalafix#147 (comment), @olafurpg wrote:

I think it's also worth exploring another approach where we have a scalafmt rule that formats the code and we extend .scalafmt.conf to support running scalafix in several independent steps. This shouldn't be too hard to support when combined with #1204

If I get it right, your idea is integrate scalafmt into scalafix (and potentially scalafix into scalafmt, although that sounds redundant?), in the core rather than in the sbt plugins.

I'll start exploring the idea of exposing a special built-in Scalafmt scalafix rule backed by scalafmt-dynamic, that would after all patches are applied.

  • sbt-scalafix should include .scalafix.conf in the cache checksum to avoid
  • sbt-scalafix could detect the presence of sbt-scalafmt in the classpath via task introspection and suggest using that rule for better results (which was the starting point of this ticket)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant