Questions tagged [detekt]

detekt is a static code analysis tool for the Kotlin programming language. It operates on the abstract syntax tree provided by the Kotlin compiler.

59 questions
12
votes
5 answers

How to get rid of from SpreadOperator performance warning that was given by Detekt while using Spring Boot?

Recently, I added Detekt analyzer to my application. After I runned detekt (./gradlew detekt), I got SpreadOperator warning in my main class of application. Warning on code: runApplication(*args) You can read about…
Seydazimov Nurbol
  • 1,404
  • 3
  • 10
  • 25
9
votes
1 answer

ktlint as the formatter in detekt

I am using detekt with ktlint for formatting my code is like below. detekt.gradle ext{ toolVersion = "1.0.0-RC16" } detekt { input = files(...) filters = ".*/resources/.*,.*/build/.*" baseline =…
user158
  • 12,852
  • 7
  • 62
  • 94
9
votes
0 answers

Ktlint vs Detekt - List of differences

I searched many websites but I didn't find any compare Ktlint vs Detekt. I need to know the differences, not the common features. I want choose one but I won't test them myself. Someone can give me few differences?
BElluu
  • 381
  • 5
  • 14
7
votes
1 answer

Detekt: Autocorrect feature is not working

I have included detekt (https://github.com/arturbosch/detekt/) in my project: root build.gradle buildscript { ext.kotlin_version = '1.3.50' ext.detekt_version = "1.0.1" repositories { google() jcenter() } …
Christopher
  • 9,682
  • 7
  • 47
  • 76
5
votes
1 answer

Disable automatic Detekt run in Gradle

I have added Detekt to my Gradle project. My intention was to invoke detekt on demand only, since it creates a lot of false positives. However, the detekt task is active by default (and breaks the build). How can I avoid this dependency? What I…
Michael Piefel
  • 18,660
  • 9
  • 81
  • 112
4
votes
1 answer

Android and Detekt: Aligning .idea CodeStyle with detekt

I have an Android project that i've set up with Detekt. I'm currently using: io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0 (Root build.gradle) io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0 (in my modules). Running gradle detekt…
Phehaz
  • 155
  • 11
4
votes
0 answers

Acquire annotation parameters (or annotation instance) from Kotlin PSI

I have a Kotlin annotation: @Retention(AnnotationRetention.SOURCE) @Target(AnnotationTarget.CLASS) annotation class Type( val type: String ) It can be used on the Kotlin classes in two ways: using the named parameter syntax, or using the…
madhead
  • 31,729
  • 16
  • 153
  • 201
4
votes
2 answers

Run detekt on all builds

It's possible to run detekt before build? (run, release...) I followed this https://arturbosch.github.io/detekt/gradletask.html But check.dependsOn detekt on build.gradle (app) don't do nothing... I already tried check.dependsOn detekt and…
felipe.rce
  • 237
  • 2
  • 8
  • 35
4
votes
0 answers

How to use external plugin in custom gradle plugin

I'm trying to write custom gradle plugin (for my self) that is using many external plugins like (detekt)... But it seems that this is not possible, I can write only internal tasks that are created by my plugin... It looks like that I have to build…
user2081554
4
votes
1 answer

How to overwrite default detekt.yml?

Is there a way to overwrite only a few config properties for detekt, and preserve most props from default-detekt-config.yml?
Juergen Zimmermann
  • 2,084
  • 7
  • 29
  • 43
3
votes
1 answer

Android Detekt Build failed

I tried to generate code report using detekt and when execute the below command in terminal gradle detekt it showing build failed with below message. * What went wrong: Execution failed for task ':app:detekt'. > Build failed with 395 weighted…
Thamarai Selvan
  • 131
  • 1
  • 6
3
votes
1 answer

Retrieve Kotlin Property type from Kotlin psi API

I'm trying to create new rule for detekt project. To do this I have to know exact type of Kotlin property. For example, val x: Int has type Int. Unfortunately, for property of type private val a = 3 I receive the following: property.typeReference…
Manushin Igor
  • 3,398
  • 1
  • 26
  • 40
3
votes
1 answer

How do a get a fully qualified domain name of class in Kotlin PSI?

I have a Kotlin data class: package a.b.c data class Example( … ) I am analyzing it with detekt which provides access to the Kotlin PSI. I'm trying to get the FQDN of my class: println(klass.nameAsName?.identifier) where, klass has a type of…
madhead
  • 31,729
  • 16
  • 153
  • 201
3
votes
1 answer

annotations vs annotationEntries in IntelliJ / Kotlin PSI

I have a Kotlin annotation: @Retention(AnnotationRetention.SOURCE) @Target(AnnotationTarget.CLASS) annotation class Type( val type: String ) It can be used on the Kotlin classes: @Type(type = "type") data class Annotated( … ) I am…
madhead
  • 31,729
  • 16
  • 153
  • 201
3
votes
2 answers

Detekt task fails only if ran without check task

I'm migrating detekt from 1.0.0.RC7-2 to the 1.0.1 and changing to use the new plugin syntax. I managed to make it work, but only when the full check task is executed. If only the detekt task is executed then an error is shown. The detekt task is…
Luciano Ferruzzi
  • 1,042
  • 9
  • 20
1
2 3 4