detekt is a static code analysis tool for the Kotlin programming language. It operates on the abstract syntax tree provided by the Kotlin compiler.
Questions tagged [detekt]
59 questions
1
vote
0 answers
How can I set up reviewdog for android and jetpack compose?
name: reviewdog
on: [ pull_request ]
jobs:
ktlint:
name: Ktlint Check Code Quality
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@main
with:
…

c-an
- 3,543
- 5
- 35
- 82
1
vote
1 answer
What is the use of LibraryEntitiesShouldNotBePublic Detekt Rule in Kotlin
I have a Kotlin Library into which I integrated the usage of Detekt static code linting. Most of the rules are clear to me and I fixed all the issues with my code except for one:
There is a rule called LibraryEntitiesShouldNotBePublic, which makes…

ali
- 1,475
- 4
- 22
- 40
1
vote
1 answer
Does not show output for all mutliple modules in an android project running the ./gradlew detekt
I am using detekt and have a android project that contains presentation, domain, and data modules.
When running ./gradlew detekt
It only show the output for the data module.
However, when I run the following ./gradlew :domain:detekt or ./gradlew…

ant2009
- 27,094
- 154
- 411
- 609
1
vote
0 answers
Pass gradle step when detekt sucessfully autocorrects
I run detekt with gradle with autocorrect enabled. I fail the build on detekt errors. This results in me running detekt twice for autocorrectable problems:
The build fails and is autocorrected.
The build passes.
Is it possible to configure detekt…

Fletch
- 4,829
- 2
- 41
- 55
1
vote
0 answers
How do I create a detekt rule to stop certain class from being explicitly referenced as a property?
In our previous project, we have a class called AbstractActor to be inherited to do specific stuff, and some of our devs might hold its reference as a constructed valOrVar parameter or KTProperty, which eventually had led to a garbage collection…

Munar Yesen
- 53
- 7
1
vote
1 answer
compilation error of jdk nashron when updated from jdk1.8 to jdk 11
Updated with more details :
My objective is to set source of below code .
source(sourceSets.map { it.javaDirectories }.flatten())
above code working fine with jdk 1.8 but when I changed to jdk 11 then
Task :quality-tools:compileKotlin…

jitendra kumar
- 2,161
- 2
- 7
- 12
1
vote
0 answers
IntelliJ Reformat Code Does Not Correct All Line Lengths
I have my IntelliJ editor configured to reformat lines that are longer than 120. It does some lines no problem. For example
val myVar = function(param1, param2, ......... paramN)
transitions to the following automatically without issue (running…

stk1234
- 1,036
- 3
- 12
- 29
1
vote
0 answers
Android and Kotlin DeteKt: Custom rules not running
Trying to create some playground over Detekt custom rules and it just doesn't work. Doesn't even try to find the rule-set file.
The gradle goes
plugins {
id 'com.android.application'
id 'kotlin-android'
…

user14387887
- 111
- 1
1
vote
1 answer
Stylish safe way to check for nullability of multiple values with Detekt
I'm using Danger Detekt (static code quality measurement system based on ktlint). I've got a function that fetches data from 8 different endpoints. Then I need to check if these values are not null and if so I return complex data type built with…

buszi
- 146
- 1
- 6
1
vote
1 answer
How to generate and use a detekt baseline using the maven plugin?
I'm trying to use detekt in a multi-module Maven project using Kotlin with the detekt-maven-plugin.
Following the instructions found here to generate a baseline with the existing issues, I tried running:
mvn detekt:cb -Ddetekt.debug=true
This does…

Erik Finnman
- 1,459
- 18
- 25
1
vote
0 answers
Detekt | finished with non-zero exit value 255
I am trying to run detektBaseline gradle task but facing following Exception
Process ‘command ‘/Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java’’ finished with
non-zero exit value 255
my project level gradle…

VW Mustahsan
- 11
- 2
0
votes
1 answer
Can't use apply() in root build.gradle.kts
I am using composite build to manage my plugins. In the same composite build, I have DetektConventionPlugin plugin shown below and I wish to apply it using this pattern: apply(). However, this is not working with composite…

Jerry Okafor
- 3,710
- 3
- 17
- 26
0
votes
0 answers
Detekt. Disabled rules are still applying
In my detekt.yml file I'm setting some rules to false for example
LongMethod:
active: false
threshold: 60
but, when I run ./gradlew detekt, the same rule is still showing up as an error.
Do I need to run another command so Detekt can see…

juske
- 95
- 1
- 12
0
votes
0 answers
How do I pass variable as argument to CLI parameter in YAML file?
I am trying to run detekt only on changed files in a pull request. The following doesn't work when I try to pass CHANGED_FILES as an argument to the input parameter for detekt.
# This workflow performs a static analysis of your Kotlin source code…

Joc
- 21
- 2
0
votes
0 answers
Detekt - Suppress an issue for a generated file
On Android, when using Jetpack Navigation SafeArgs, some classes are generated by the lib and those classes cause some issues like "ThrowsCount", "UseRequire" and "MaxLineLength".
Is there a way to exclude thoses classes from being analyzed by…

Leonardo Sibela
- 1,613
- 1
- 18
- 39