-
Notifications
You must be signed in to change notification settings - Fork 185
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
More complex custom rules: Scalafix Plugins/Bundles #304
Comments
I like this solution and it's indeed the occam's razor approach to the problem: libraries solve the problem of bundling multiple classes and deps after all. Compared to what proposed in #280 it carries a bit more friction for authors, because it requires publishing (so PRs like mine to the cats repo would have required much more dedication by the maintainers). Can we maybe provide a dynamic way of loading the plugins if they don't carry external dependencies? For libraries (e.g. the cats example) I like the approach of hosting the rewrite in the same repo of the code they are fixing, but requiring to publish a library may drive people in the opposite direction (an external repo), especially if the person authoring and maintaining the rewrites is not one of the core maintainers. I wouldn't want to cause fragmentation between:
Also, we must be careful in enforcing compatibility between the plugin's scalafix version and the "host's" scalafix version. Overall a big 👍 , I just would challenge the UX for authors a bit more. |
Great point Gabro. I agree this proposal does increases friction for library maintainers like in the cats example. I have a complementary idea how we could support multi-file rewrites: instead of expanding
If the If that sounds like a good idea, then I can update the description of #280 and we keep both this issue and #280 open. |
After offline discussions with @gabro, we agreed "bundle" might be a better name than "plugin". |
This issue has now been fixed thanks to using JDK Service Loaders (https://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html). This means that as long as a custom rule is on the --tool-classpath of a scalafix rule (can be done with |
Opening this issue to discuss a potential feature that supersedes #280 and #111.
Problem: advanced custom rewrites are currently limited to either
github:org/repo
rewrites #280.Solution: support scalafix "plugins", which are a bundle of rewrites that can be invoked by their name instead of
scala:fqn
/file:path/Rewrite.scala
. A scalafix pluginThe API to implement a plugin can be something like
The API to install rewrites can be something like this
Example plugins that could be implemented:
The text was updated successfully, but these errors were encountered: