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

Add Cats RemoveInstancesImport rule #31

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

armanbilge
Copy link
Member

Fixes #7.

Sadly I am out of my depth with this one. Seems that this rule was written with the Scalafix v0 API and I'm not quite sure how to make it work. Perhaps it needs to be rewritten with the v1 API.

@DavidGregory084
Copy link
Member

DavidGregory084 commented Jul 18, 2022

I made a start at porting this one to scalafix v1 API in 82b45b0, but I'm a bit out of my depth as well. I'm not sure how to connect synthetics to their positions in v1, something which the old rule used to determine the scope of the imports it was rewriting.

@DavidGregory084
Copy link
Member

I think we can get the synthetics for a given Term by simply calling .synthetics on it, but that doesn't work for e.g. Template, which is a Tree but not a Term.

@TonioGela
Copy link
Member

Hey people, I took the liberty of attempting to fix this and apparently I've managed to do that. The only thing I'm not sure about is this change:

  private def catsKernelConversion(symbol: Symbol): Boolean =
-    symbol.value.contains("cats/kernel") && symbol.value.contains("Conversion")
+    symbol.value.contains("cats/kernel") // && symbol.value.contains("Conversion")

I think that this specific predicate was referring to a specific .*Conversion.* object under the cats/kernel package that was containing all the conversions, that is not present anymore (as far as I can tell). I don't know which might be the better choice, maybe symbol.value.contains("cats/kernel/instances") given that all the instances seems to be sitting there?

@TonioGela TonioGela requested a review from DavidGregory084 July 5, 2024 11:31
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

Successfully merging this pull request may close these issues.

Lint cats instance imports
3 participants