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

How to count references to a variable or function in Kotlin?

The question is about static compile time analysis. Let's say there is a file-level const val: const val SOME_CONST_VAL = "SOME_CONST_VAL" How is it possible to get the number of usages for this SOME_CONST_VAL? To clarify: It's something IDEs…
Andrei K.
  • 534
  • 7
  • 20
0
votes
0 answers

DeteKt: сheck for the use of the fragment constructor in Android

Is it possible to create DeteKt rule for checking is the Android fragment constructor used directly in the code instead newInstance? I would like to create checks that prohibit the creation of a custom constructor for a fragment as well as the…
po4yka
  • 151
  • 2
  • 7
0
votes
1 answer

Getting Schema validation: Incompatible types in detekt.yml in Android Studio

Any way I can fix the schema warning in detekt.yml I am attaching the screenshot and open to add more details Minimum reproducible detekt.yml below build: maxIssues: 0 excludeCorrectable: false weights: complexity: 2 …
AndroidEngineX
  • 975
  • 1
  • 9
  • 22
0
votes
1 answer

How to check usage of 'it' parameter in lambda with Detekt custom rule?

I want to write a Detekt rule which disallows usage of implicit "it" variable in a multi-line lambda. I've written method override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) but I don't know how Check if the lambda contains…
IL_Agent
  • 707
  • 3
  • 16
0
votes
1 answer

Configure rules in Detekt

I am adding Detekt to a new project. But, I find that some rules are too strict. How can I implement my own thresholds for a few rules? I don't want to use Baseline files, because this is new code and we don't want to consider some things code…
FailedUnitTest
  • 1,637
  • 3
  • 20
  • 43
0
votes
1 answer

Running detekt from the command line locally doeesn't produce problems

Android detekt 1.19.0 When running this commmand I get the following output but not classes that have failed for the rules. ./gradlew detekt 37 kotlin files were analyzed. Complexity Report: - 1,377 lines of code (loc) - 1,130…
ant2009
  • 27,094
  • 154
  • 411
  • 609
0
votes
1 answer

Need to block Android run on failed gradle task

I have an android project in Android studio that I would like to use detekt as a static code analyzer. I can run detekt through a gradle task and I am able to queue it up before the run of the app by using the Android run configurations, but I…
DamosCas
  • 23
  • 3
0
votes
0 answers

how to attach a task to run after the tasks from a plugin in gradle

I have installed the detekt plugin in gradle-kotlin with plugins { id("io.gitlab.arturbosch.detekt").version("1.10.0") } This yields tasks for me when I run tasks: Verification tasks ------------------ check - Runs all…
qkslvrwolf
  • 179
  • 2
  • 10
0
votes
1 answer

SonarQube Is there a gradle setting in detekt gradle plugin to generate report on remote host instead of in a file

When I use sonarqube plugin I'm not able to generate report on remote host on using my specific branch as lateast version is not supporting it and branch.name is deprecated So When I use detekt plugin it generates report in file locally and not on…
Appy
  • 63
  • 1
  • 4
0
votes
0 answers

Detekt plugin not able to download from Maven central

I am working with Kotlin and want to do static analysis using Detekt plugin. My problem is, when I want to download it from Maven central repository, it is giving me below error. But when I use company's repository (Nexus), it does not give me any…
Radiant
  • 360
  • 3
  • 26
0
votes
1 answer

How can I use detekt and its visitor to navigate over the AST of a given Kotlin file?

I need to check how can I navigate over the Kotlin AST of a given file. I do not know how can I pass this file to get a generated AST nor how can I navigate over its nodes using the Visitor pattern. My goal is to check the usage of some Kotlin…
albert
  • 182
  • 1
  • 4
0
votes
3 answers

Define Kotlin's detekt version as extra property (ext)

Groovy allows definition of extra properties for the project in ext. I wanted to define Detekt's version inside groovy's extra properties. Detekt is a static code analysis tool for Kotlin lang. However when I do it in the folloing way: buildscript…
0
votes
1 answer

detekt snake case package

I added detekt to my app and it is complaining about my package names conventions. I use the package snake_cased and the class CamelCased. For example: package com.my_package class MyClass And the output from detekt is the…
jonathanrz
  • 4,206
  • 6
  • 35
  • 58
-1
votes
1 answer

.git/hooks/pre-commit: line 33: detekt: command not found

I am trying to use detekt on my android project but when i try to commit using sourcetree i get this error. Checking prerequisites Collecting modified files Running detekt .git/hooks/pre-commit: line 33: detekt: command not found print of the error…
1 2 3
4