Closed vascorsd closed 2 years ago
Thanks for providing the test project! I checked out your repository to /tmp/ineninaru
. When I change the build.toml
as follows, the plug-in creates the SemanticDB files which scalafix complained about:
diff --git a/build.toml b/build.toml
index 8333d6e..4582a76 100644
--- a/build.toml
+++ b/build.toml
@@ -29,8 +29,11 @@ scalaOptions = [
"-Xlint:private-shadow",
"-Xlint:type-parameter-shadow",
-# "-P:semanticdb:sourceroot:.",
-# "-P:semanticdb:targetroot:./build/semanticdb",
+ "-P:semanticdb:synthetics:on",
+ "-P:semanticdb:failures:warning",
+ "-P:semanticdb:sourceroot:/tmp/ineninaru/",
+ "-P:semanticdb:targetroot:/tmp/ineninaru/build/semanticdb",
+ "-Xplugin-require:semanticdb"
]
testFrameworks = ["utest.runner.Framework"]
I got the settings from here. You were using relative paths. Since the Bloop server runs from a different folder, the current working directory does not point to your project. Ideally, SemanticDB should report an error if it did not find any Scala files.
With the following steps:
seed bloop
bloop compile client server
coursier bootstrap ch.epfl.scala:scalafix-cli_2.12.11:0.9.15 -f --main scalafix.cli.Cli -o scalafix
TOOL_CLASSPATH="$(
coursier fetch --cache .scalafix-rules \
com.github.vovapolu:scaluzzi_2.12:0.1.7 \
com.github.liancheng:organize-imports_2.12:0.2.1 \
-p
)"
./scalafix --tool-classpath "$TOOL_CLASSPATH" \
--scalac-options "-Ywarn-unused" \
--auto-classpath \
--check \
--verbose \
--stdout
The final output was:
info: Processing (0/4) /tmp/ineninaru/src/server/configuration/Configuration.scala
--- /tmp/ineninaru/src/server/configuration/Configuration.scala
+++ <expected fix>
@@ -1,7 +1,7 @@
package configuration
-import ciris._
import cats.implicits._
+import ciris._
final case class Configuration private (
serverHost: String,
info: Processing (1/4) /tmp/ineninaru/src/server/IneninaruServer.scala
/tmp/ineninaru/src/server/IneninaruServer.scala:15:39: error: [Disable.getMessage] Untrusted third party library must be called from IO, or blessed in scalafix.conf
.tapError(err => putStrLn(err.getMessage))
^^^^^^^^^^
/tmp/ineninaru/src/server/IneninaruServer.scala:11:6: error: [Disable.Any] Any is disabled and it got inferred as `*(CanFail.canFail[Any])`
(for {
^
/tmp/ineninaru/src/server/IneninaruServer.scala:13:7: error: [Disable.Any] Any is disabled and it got inferred as `*(CanFail.canFail[Any]).flatMap[Console, Throwable, Unit]({() => *.map[Unit]({() => *})})`
conf <- Configuration.definition
^
/tmp/ineninaru/src/server/IneninaruServer.scala:13:15: error: [Disable.Any] Any is disabled and it got inferred as `*(catz.taskConcurrentInstance[Any], catz.zioContextShift[Any, Throwable])`
conf <- Configuration.definition
^
/tmp/ineninaru/src/server/IneninaruServer.scala:13:15: error: [Disable.Any] Any is disabled and it got inferred as `*(catz.taskConcurrentInstance[Any], catz.zioContextShift[Any, Throwable])`
conf <- Configuration.definition
^
info: Processing (2/4) /tmp/ineninaru/src/protocol/proto.scala
--- /tmp/ineninaru/src/protocol/proto.scala
+++ <expected fix>
@@ -1,3 +1,3 @@
package ineninaru
-case class HiMome(say: String)
+final case class HiMome(say: String)
info: Processing (3/4) /tmp/ineninaru/src/client/IneninaruClient.scala
I've spent too many hours already trying to be able to call and use scalafix directly from the command line as any sane cli application should be able to. At this point I'm convinced it's almost impossible to simply use that tool without some kind of integration in the build tool. I'd like to be proven wrong if that's possible. So it would be nice to see if it's possible or not to have it working with seed, documentation, examples or needed additions to the tool for it to work.
I have an example project here - https://github.com/vascorsd/ineninaru
The pains points I've found are the following at least:
Some examples runs: