apache / apache/pekko

Add/enable scalafix in pekko

Open
#414 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
1.6k
Forks
211
Avg merge
1d 6h
Merged PRs (30d)
89

Description

It would be ideal to have [scalafix](https://scalacenter.github.io/scalafix/) along with its addons such as [organize-imports](https://github.com/liancheng/scalafix-organize-imports) to automatically

* Remove unused imports
* Organize imports to avoid unnecessary nesting, FQCN usages etc etc
* Sort imports

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.

```scala
import org.apache.pekko
```

So that any future references to code within Pekko packages just needs `pekko.` which is the same as how the code was in Akka and the other one is our complicated usage of [paradox](https://developer.lightbend.com/docs/paradox/current/) 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

* https://github.com/scalacenter/scalafix/issues/1792
* https://github.com/liancheng/scalafix-organize-imports/issues/312
* https://github.com/scalacenter/scalafix/issues/1793

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.