-
-
Notifications
You must be signed in to change notification settings - Fork 777
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
Run Detekt as Kotlin Compiler Plugin #2119
Comments
Thanks for reporting interest in this approach and posting the links. |
+1 |
I had a proof of concept of the "naive" approach working some time ago. The main problems I saw:
But it's a huge win in terms of performance because detekt can use the result of Kotlin compilation directly instead of effectively recompiling (and it also means detekt would use the exact same compiler configuration as when the Kotlin code is compiled). And the classpath conflicts for Gradle should go away if committing to this direction as detekt wouldn't need to be on the Gradle plugin classpath anymore. I can't see how |
I've prototyped an approach based on the Detekt findings next to kotlinc findings |
Nice! That's a good start. To get the most advantage though we'd want to be able to run detekt during the project compilation instead of as a separate task - that's what I meant when I said
Because |
Great job! Is the runtime much different using that approach or just a stepping stone to using it during the compilation stage? |
I'm not sure if I understand you 100%. We are running inside the
It feels much faster. Also the |
I'll need to debug to see what's actually happening with the plugin, but from what I can see in the POC you're providing Yes it's all happening in the As I said I haven't run this yet though so apologies if that's not the case, but I ran into similar issues when experimenting with this so wanted to flag it. |
Closing this in favor of the new repository https://github.com/detekt/detekt-compiler-plugin. |
To improve the feedback cycle of errors to the developer and the possible performance when doing type resolution, Detekt could be implemented to run as a Kotlin compiler plugin. This would bring the behavior closer to a tool like ErrorProne.
We're investigating this internally at Uber to see if we can get any wins out of this approach.
A naive approach/prototype would be to use the AnalysisHandlerExtension, like the JVM ABI plugin and visit the KtFiles.
A more interested approach, would be to figure out wiring for the existing checkers based on CallChecker.
The text was updated successfully, but these errors were encountered: