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/enable scalafix in pekko #414

Open
mdedetrich opened this issue Jun 17, 2023 · 2 comments
Open

Add/enable scalafix in pekko #414

mdedetrich opened this issue Jun 17, 2023 · 2 comments

Comments

@mdedetrich
Copy link
Contributor

mdedetrich commented Jun 17, 2023

It would be ideal to have scalafix along with its addons such as 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.

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
Copy link
Contributor Author

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

@bjaglin
Copy link
Contributor

bjaglin commented Jul 19, 2023

FTR, liancheng/scalafix-organize-imports#312 was transferred to scalacenter/scalafix#1829

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

No branches or pull requests

2 participants