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

scalafix can't find 'RoughlyMapValues' #517

Open
natansil opened this issue Jan 31, 2022 · 9 comments
Open

scalafix can't find 'RoughlyMapValues' #517

natansil opened this issue Jan 31, 2022 · 9 comments

Comments

@natansil
Copy link

scalafix dependency:[email protected]:scala-collection-migrations:2.6.0
[error] (Compile / scalafix) scalafix.sbt.InvalidArgument: Unknown rule 'RoughlyMapValues'

This is how I setup my sbt.build file

@SethTisue
Copy link
Member

@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...?

@sjrd
Copy link
Member

sjrd commented Feb 12, 2022

@mlachkar Are you familiar with the above rule and/or why it is not found?

@mlachkar
Copy link
Contributor

mlachkar commented Feb 14, 2022

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:[email protected]:scala-collection-migrations:2.6.0

Tell me if you need more help!

@natansil
Copy link
Author

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.

@SethTisue
Copy link
Member

relevant: #107

@natansil
Copy link
Author

@SethTisue
Copy link
Member

SethTisue commented Oct 28, 2022

Sounds plausible — do we have any test coverage for it?

@olegbonar
Copy link

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

@SethTisue
Copy link
Member

@olegbonar Thank you for looking into it! Would you be interested in submitting a PR that improves the documentation...?

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

No branches or pull requests

5 participants