Skip to content

Conversation

TonioGela
Copy link
Member

I've tried to begin addressing #46.
The solution uses mutability since essentially the APIs ask you to (the only alternative is traversing the entire document multiple times).

The solution is also naive and it's merely syntactical: once it finds the expression Right(()) searches for one of those imports in any point of the document:

cats.syntax.all._
cats.syntax.either._
cats.syntax.either.catsSyntaxEitherObject

and if any of those is present it DOESN'T add the cats.syntax.either._ import.

A nice rework could include:

  1. Making the rule semantical, so that we can check that the function called is exactly scala.util.Right.apply
  2. Searching for every occurrence of the expression if any of those imports is present but starting from it and following the parent trees. If any of the occurrences doesn't have those imports in the chain of parent trees then adding a global import is more reasonable (despite the fact that it could always clash with a local import).

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.

1 participant