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

feature parity with others klint gradle plugins #616

Closed
6 tasks
LifeIsStrange opened this issue Jun 18, 2020 · 2 comments
Closed
6 tasks

feature parity with others klint gradle plugins #616

LifeIsStrange opened this issue Jun 18, 2020 · 2 comments
Labels

Comments

@LifeIsStrange
Copy link

LifeIsStrange commented Jun 18, 2020

I would like spotless to become the best reference solution for Klint.

There is at least two competitors:
https://github.com/jeremymailen/kotlinter-gradle with ~100 commits it seems a bit young but:
like him does spotless supports:

  • incremental build support (performance matters)
  • file reports
  • *.kts source support
  • ability to have different code style between .kt and .kts files (a minor feature)

https://github.com/jlleitschuh/ktlint-gradle this one has had a lot of work with its ~600 commits (still less than spotless)

  • Gradle build caching
  • ???

My biggest question is: which one is the fastest (using intellij) ?
Maybe that #601 would help performance
Maybe that your current use of reflection (#524) might harm performance too ?

What do you think ?

@nedtwigg
Copy link
Member

nedtwigg commented Jun 18, 2020

For every formatter that Spotless suppports, there are multiple formatter-specific plugins on the plugin portal. I believe that is largely because once a plugin has been published, you cannot update its tags or descriptions. e.g. if you search the portal for google-java-format or ktlint, Spotless does not show up. We will be fixing that soon by publishing at a new id, com.diffplug.spotless, and adding tags for all the formatters we support today.

In terms of performance, Spotless already supports incremental build and the local build cache. We have to fix #566 before we can support remote build cache.

A less-well-known advantage is that we cache classloaders across subprojects and daemon runs, which allows the JIT to perform much better than a simple "every project and build gets its own classloader". At the time we implemented that feature a long time ago, it was a many-X performance improvement, perhaps the other projects implemented that as well, I don't know.

A huge performance improvement is ratchetFrom 'origin/main', which allows you to:

  • keep copyright headers up-to-date
  • migrate your format gracefully
  • really really really big speed improvement (~10-100x)

An ooper-dooper performance improvement is our IDE hook, which currently has only a VS Code plugin but could easily have an IntelliJ plugin as well.

If you want separate format for .kt and .kts, you can do that if we make this method public and rename it to format:

import com.diffplug.gradle.spotless.KotlinExtension

spotless {
  kotlin {
    target 'src/**/*.kt'
    ktlint()
  }
  format 'kotlinScript', KotlinExtension, {
    target 'src/**/*.kts'
    ktlint()
  }

I am confident that our use of reflection has a too-small-to-measure impact on performance, because per-format-call we are only making one or two reflection calls. The main problem with our reflection is that it's hard to read. #524 would fix this. And that hard-to-read part cascades into missing features like #142 and #409.

So that's the landscape. if you would like to make improvements to our docs or implementation anywhere, we would be happy to assist you!

@nedtwigg
Copy link
Member

Just FYI, the example above with format 'kotlinScript', KotlinExtension, { will work as of plugin-gradle 4.4.0 and higher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants