Best way to handle false unused imports in intellij

Intellij mistakenly noted some Scala implicits imports as unused. Is there a way to prevent it from deleting this import data if it is optimized for a particular import and does not exclude optimized import for the entire project?

+4
source share
2 answers

I'm afraid not, I had similar problems, especially when using akkaand importing an implicit execution context from ActorSystemin some cases. I recommend defining a value instead of importing. One such example would be:

// Avoid importing the execution context like this
class MyActor extends Actor {
  import context.system.dispatcher
}

// Define it explicitly instead
class MyActor extends Actor {
  implicit val ec = context.system.dispatcher
}

Hope this helps you.

+6
source

Source: https://habr.com/ru/post/1673856/


All Articles