spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Support for Kotlin Formatter Detekt

Open JLLeitschuh opened this issue 8 years ago • 21 comments

There's another formatter with much more configuration called Detekt that some kotlin projects may want to use instead of Ktlint.

(Personally, I still love Ktlint but some people want options). It would be nice if there was an integration with Detekt built in to Spotless..

JLLeitschuh avatar Sep 21 '17 15:09 JLLeitschuh

Sounds like it'd be a great addition. Here's how to add it, we'd be happy to help any contributor if they get stuck.

nedtwigg avatar Sep 21 '17 18:09 nedtwigg

Hi @saschpe. Looks like you've done a lot of great work, but the reflection part is pretty tricky. Just wanted to let you know that #524 might be an easier approach.

nedtwigg avatar Feb 13 '20 19:02 nedtwigg

Ok, I'll take a look.

saschpe avatar Feb 14 '20 06:02 saschpe

Just to say that I believe that detekt and klint can (or at least should be able to) be used altogether. A typical use case would be to lint with klint and to do static analysis with detekt.

LifeIsStrange avatar Jun 18 '20 17:06 LifeIsStrange

Any progress? I see there are commits referencing this issue, but there is no PR. @saschpe is it a matter of opening a PR from your detekt branch in your fork, or are there any issues?

erikhuizinga avatar Nov 20 '20 12:11 erikhuizinga

Not really, I lost interest once Klint development started again. A while ago, it had very controversial default settings that where not modifiable. This changed so at least I don't have any further need for Detekt. Sorry.

saschpe avatar Nov 20 '20 12:11 saschpe

ktfmt is another option which works well

nedtwigg avatar Nov 20 '20 16:11 nedtwigg

I agree with @nedtwigg's comment on ktfmt! But just to note that it requires Java 11, so it doesn't yet work with Android projects.

I understand though that the next Android Studio version will be based on Java 11, which should be a big milestone towards allowing Android projects to be built with Java 11, and thus allowing ktfmt to be adopted in that ecosystem.

jbduncan avatar Nov 20 '20 19:11 jbduncan

Does ktfmt do static code analysis like detekt, or is it just a formatter/style linter like ktlint?

erikhuizinga avatar Nov 20 '20 21:11 erikhuizinga

Just a formatter. We'll merge anything that someone is actually using, but I don't think Spotless provides much benefit to static analysis tools. See this discussion for details.

nedtwigg avatar Nov 20 '20 21:11 nedtwigg

Then I guess that you can close this issue? Any future inquiries about detekt will find this issue or can be forwarded to it, unless the needs/possibilities change.

For now the recommendation is to use detekt separately.

erikhuizinga avatar Nov 20 '20 21:11 erikhuizinga

From @rougsig in issue above:

The main functionality that I want to get from usage spotless with detekt is git ratchet.

That's a good usecase! As mentioned earlier in this thread:

We'll merge anything that someone is actually using

Reopening this issue for now until rougsig finished their PR or gives up :)

nedtwigg avatar Jan 12 '22 19:01 nedtwigg

any update on this ?

emismo avatar May 16 '23 14:05 emismo

Nicola here from the Detekt team: we'd love to see this happening. If someone is looking into adding support for Detekt to Spotless we can provide some help

cortinico avatar May 17 '23 09:05 cortinico

?

erfansn avatar Apr 27 '24 14:04 erfansn