-
Notifications
You must be signed in to change notification settings - Fork 185
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
Unclear errors when running semantic rules with a minimal set of scalafix-cli flags #1957
Comments
Some semantic rules such as As you can already tell, it can be tricky to get all the scalafix-cli options right, and compilation must be triggered beforehand. All this complexity is abstracted by sbt-scalafix, so I recommend using it whenever possible, especially for semantic rules. If you don't use sbt, support for other build tools is available. I am keeping this issue open, since documentation could be improved, and the error message more actionable ( |
Yeah I definitely see why you would recommend sbt-scalafix as this is not completely straightforward for someone new to the scalafix-cli. I tried to do this:
which gives the repeated error:
I am not entirely sure how to set the |
The thing is that it really depends on how your build is setup: where class files are generated, semanticdb options, etc. That's why it makes sense to use the integration for your build tool. Maybe you can tell more about your use-case? Anyway, here is how it should look like with the simplest sbt build I can come up with:
|
Thanks for providing a minimal example @bjaglin. The potential use-case of the scalafix-cli that I am looking into is whether it can run as part of pre-commit locally in a reasonable amount of time (less than 10 seconds). I used to have sbt-scalafix as part of my pre-commit hook locally, however it simply took too long to run so I had to remove it. I actually had a similar issue with sbt-scalafmt but when using a slim version scalafmt slim of scalafmt it works really fast (1-2 seconds to format all .scala files). And I can easily run it like this: |
I see. You should definitely be able to get scalafix to run in ~10s, as long as your code is compiled ahead of time with semanticdb information, and you capture the build structure as CLI args. Also, you won't benefit from incremental features from sbt-scalafix though, so runtime will be directly proportional to the number of source files you have.
Did you consider using sbtn for your pre-commit hook? If you have a sbt server running locally, the startup time should be minimal, and you would benefit from sbt-scalafix incrementality, so the run could take only a couple of seconds. |
When using scala-cli, from the root of my sbt project, as mentioned in the documentation:
I get the following error:
I am using Scala 3.4.0. But adding the mentioned Scala compiler options does not seem to do the trick either. However, when using the sbt plugin for scalafix,
sbt "scalafix --check"
(0.12.0), I have no issues at all.I also tried to use the scalafix-cli retrieved with
cs install scalafix
but I get the exact same error as above.The text was updated successfully, but these errors were encountered: