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
3
votes
1 answer

How do I enable type resolution in detekt?

detekt is alerting me about the SpreadOperator rule. According to this issue, the rule can be suppressed in certain circumstances when type resolution is enabled. I can't find any documentation or examples of how to enable type resolution, though.…
Quincy Bowers
  • 390
  • 2
  • 15
3
votes
0 answers

Custom gradle script for Detekt with multi-module project

I'm trying to create a custom gradle task that will run the different detekt profiles I have setup. Here is my Detekt config: detekt { version = "1.0.0.RC6-4" profile("main") { input = "$projectDir/app/src/main/java" output…
isuPatches
  • 6,384
  • 2
  • 22
  • 30
2
votes
0 answers

How can I access local.properties in Github Action yml file for ci?

I get data from local.properties in build.gradle like this. android { signingConfigs { debug { Properties properties = new Properties() …
c-an
  • 3,543
  • 5
  • 35
  • 82
2
votes
1 answer

JetPack Compose - Best practices for method length

I am trying to integrate detekt with JetPack Compose project and as a rule LongMethod: active: true threshold: 60 and as compose recommend passing each parameter in separate line the method length exceeds the 100 lines of code, So I am…
Sahar
  • 301
  • 1
  • 6
2
votes
0 answers

My CI build fails because of detect property

I just recently updated my arturbosch detekt library in my android app to 1.20.0-RC1 but when I run my build using bitrise CI tool, I get this error message: I have checked my detekt config file and "formatting" is spelt correctly. What could be…
Ugo Onuoha
  • 21
  • 2
2
votes
1 answer

Detekt. Different thresholds for same rule

I'm using Detekt and I need to configure LargeClass rule. I want to set different thresholds for production and test classes. Is it possible to configure it such way?
DamienMiheev
  • 998
  • 8
  • 31
2
votes
0 answers

Error while setting up Detekt custom rules

I have setup Detekt in a multi module project. Below is my root level build.gradle tasks.register("detektAll", Detekt) { description = "Custom Detekt build for all modules" parallel = true setSource(file(projectDir)) …
varun
  • 465
  • 6
  • 23
2
votes
1 answer

Detekt return type annotations always empty

I am trying to write a check to prevent returning a Type with a certain annotation. Such as, const val TEST_CONTENT = """ | package sample.test | | @Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS) …
yahya
  • 4,810
  • 3
  • 41
  • 58
2
votes
1 answer

How to enable type resolution for custom detekt gradle task?

I have a custom gradle task to run detekt only on files passed as argument. tasks.register("detektCustom", io.gitlab.arturbosch.detekt.Detekt.class) { detektTask -> detektTask.config.from("$rootDir/app/config/detekt/detekt.yml") …
Sandesh Baliga
  • 579
  • 5
  • 20
2
votes
1 answer

How to suppress WildcardImport and MatchingDeclarationName for Detekt?

I need to suppress two errors: WildcardImport and MatchingDeclarationName. Probleme is that it is need to be applied to the whole file, is there any way to do this?
user12848156
  • 135
  • 2
  • 9
2
votes
1 answer

detekt NoUnusedImports not reported

In my Android gradle project, I added detekt v1.0.0.RC8. I generated default .yml file by executing: ./gradlew detektGenerateConfig and ran the check: ./gradlew detektCheck The plugin found a couple of issues of type TooGenericExceptionCaught,…
liminal
  • 1,144
  • 2
  • 13
  • 24
2
votes
1 answer

detekt doesn't generate report

I'm building my project by maven. The detekt configuration was added based on the official documentation: org.apache.maven.plugins maven-antrun-plugin 1.8
Bizon4ik
  • 2,604
  • 4
  • 20
  • 46
2
votes
2 answers

EmptyClassBlock lint complaint on Json TypeToken

I have a piece of kotlin code as below, gson.fromJson>(data, object : TypeToken>() {}.type) Detekt doesn't like it and complaint EmptyClassBlock - [] Is there any way I could…
Elye
  • 53,639
  • 54
  • 212
  • 474
1
vote
0 answers

Detekt VarCouldBeVal rule doesn't seem to work

I've noticed that Detekt doesn't report issues with this code fun main() { var thisCouldBeVal = "this could be val" println(thisCouldBeVal) } Isn't this a clear case where VarCouldBeVal rule should be triggered, or am I missing…
Eugene
  • 374
  • 1
  • 2
  • 10
1
vote
1 answer

Detekt setting for exclude is ignored

How can I exclude the sample folder from the following rules? with this configuration it is not working and detekt keeps parsing the sample folder UndocumentedPublicClass: active: true excludes: &samples - '**/rd/compose/samples/**' …
Rulogarcillan
  • 1,130
  • 2
  • 13
  • 23