Open natansil opened 2 years ago
@sjrd the scalafix rules in this repo were developed at the Center; is there someone there who would like to take a look at this...?
@mlachkar Are you familiar with the above rule and/or why it is not found?
The rules provided by scala-collection-compat
are the following:
Collection213CrossCompat
Collection213Upgrade
Collection213Experimental
Collection213Roughly
So there is no rule called RoughlyMapValues
. I guess its name is Collection213Roughly
.
The easiest way to run those rules is to add scalafix in your plugin list
// plugins.sbt
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.33")
then add the dependency to this rule in your build:
// build.sbt
ThisBuild / scalafixDependencies += "org.scala-lang.modules" %% "scala-collection-migrations" % "2.6.0"
And then add them to the configuration of scalafix: .scalafix.conf
rules = [
Collection213CrossCompat,
Collection213Upgrade,
Collection213Experimental,
Collection213Roughly
]
And then launch sbt shell, and run scalafixAll
After doing so, you can remove the rules, since it's only needed for one run only!
You can also run with scalafix command through sbt shell
scalafixAll dependency:Collection213Roughly@org.scala-lang.modules:scala-collection-migrations:2.6.0
Tell me if you need more help!
Hi @mlachkar,
Thank you so much for answering in a detailed manner.
The documentation states that there is a rule called RoughlyMapValues
for the specific breaking change of mapValues
returning a MapView
instead of Map
I've tried running scalafix with Collection213Roughly (doc states that it fixes "Stream is replaced with LazyList"), it runs successfully, but it doesn't fix any of the mapValues lines of code.
can it be that https://github.com/scala/scala-collection-compat/blob/main/scalafix/rules/src/main/scala/scala/fix/collection/Collection213Roughly.scala just doesn't work?
Sounds plausible — do we have any test coverage for it?
This one took me a while to solve. I guess the documentation is quite misleading: there is no such rule as RoughlyMapValues
, it's named Collection213Roughly
instead. In order to run it one should provide explicit configuration via .scalafix.conf
for example:
Collection213Roughly.strictMapValues = true
Collection213Roughly.strictFilterKeys = true
By default all the fixes are disabled somehow
@olegbonar Thank you for looking into it! Would you be interested in submitting a PR that improves the documentation...?
scalafix dependency:RoughlyMapValues@org.scala-lang.modules:scala-collection-migrations:2.6.0 [error] (Compile / scalafix) scalafix.sbt.InvalidArgument: Unknown rule 'RoughlyMapValues'
This is how I setup my sbt.build file