apache / pekko

Build highly concurrent, distributed, and resilient message-driven applications using Java/Scala
https://pekko.apache.org/
Apache License 2.0
1.17k stars 139 forks source link

Add/enable scalafix in pekko #414

Open mdedetrich opened 1 year ago

mdedetrich commented 1 year ago

It would be ideal to have scalafix along with its addons such as organize-imports to automatically

And many other rules, some of which already exist here https://github.com/apache/incubator-pekko/blob/f84e8db3cbdbc05743cb06a2d4264d1a7ce01b96/.scalafix.conf . Although historically people have used Intellij to sort/clean imports, this is not ideal for many reasons i.e. it ties Pekko to a specific IDE, Intellij isn't always correct due to the same reasons why it also reports uncompilable code incorrectly and most critically we can't use it in github actions CI to enforce the rules are consistently applied and don't rot over time.

It would have been great to have already done this, particularly soon after we integrated scalafix some time ago however there are some features of Pekko's codebase which would cause issues if we enable scalafix. The first one is that in order to avoid excessive boilerplate due to adding org.apache to our root package, in Scala source files we have a "root" import, i.e.

import org.apache.pekko

So that any future references to code within Pekko packages just needs pekko.<something> which is the same as how the code was in Akka and the other one is our complicated usage of paradox directives which when combined with the first problem of root imports makes things even more complicated (i.e. some source files such as https://github.com/apache/incubator-pekko-http/blob/fb224dfba74d03d88866d5c40d63ebd9729cdded/docs/src/test/scala/docs/http/scaladsl/HttpServerExampleSpec.scala have the same import org.apache.pekko multiple times but thats because the additional cases of that import is going to be within generated documentation otherwise when people copy code from the docs they will miss an import).

I created issues upstream documenting these cases

mdedetrich commented 1 year ago

@He-Pin Pinging you because you were asking about this.

bjaglin commented 1 year ago

FTR, https://github.com/liancheng/scalafix-organize-imports/issues/312 was transferred to https://github.com/scalacenter/scalafix/issues/1829