https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
detekt
  • d

    dead.fish

    04/01/2020, 11:14 PM
    Out of interest, I'm a happy Detekt user since the early milestone releases and I was wondering if there are any plans to actually stabilize certain versions? I feel Detekt is moving quickly paced like ever before, so I have the fear that potential bugs / instabilities could lurk into it. Up until recently, I was using it mainly in small teams, so I could easily argue a version bump in case of an issue or fight this out myself, but now I basically want to throw it at a team of 30+ developers replacing Sonarqube (partially). Maybe I just missed to see an "official" notion on this topic anywhere, and maybe it's not so bad to move quickly and fix things after all, but on the other side new issues are easily introduced as well, and a static code analysis tool should be - first and foremost - reliable and stable in how it works and what it reports. So, tl;dr, will Detekt ever have stable, maintained versions?
    b
    a
    • 3
    • 8
  • s

    seb

    04/02/2020, 7:30 AM
    afaik Sonarqube uses Detekt under the hood for Kotlin code, so no need to replace it
    m
    m
    g
    • 4
    • 5
  • a

    Artur Bosch

    04/02/2020, 4:47 PM
    Are there any features sonar provides which you currently miss for Kotlin?
    d
    • 2
    • 2
  • j

    Javier

    04/03/2020, 8:03 AM
    I was trying yesterday the Detekt plugin and it is amazing, the only thing I want is an option to override the reformat code (control alt L) to use detekt autoformatting because in some places, the detekt formatting is different from intellij formatting.
    👍 2
    s
    • 2
    • 4
  • g

    Gopal S Akshintala

    04/03/2020, 5:04 PM
    What’s the official/recommended way of integrating detekt into SonarQube? (I see the
    sonar-kotlin
    plugin offered by detekt is not official and there is SonarKotlin official from SonaQube which says you can pull detekt reports), I am confused which way to go!
    m
    a
    • 3
    • 4
  • a

    Anthony f

    04/06/2020, 12:41 PM
    Hey, is there a way to easily setup a gradle task to autoCorrect a single rule with Detekt ?
    a
    • 2
    • 3
  • d

    dead.fish

    04/07/2020, 11:46 AM
    I don't know what changed in 1.7.4, but when I run detekt in parallel on all configured modules, I get these weird classloading issues:
    Caused by: java.lang.NoClassDefFoundError: kotlin/io/CloseableKt
            at io.gitlab.arturbosch.detekt.api.internal.YamlConfig$Companion.load(YamlConfig.kt:67)
            at io.gitlab.arturbosch.detekt.api.internal.YamlConfig$Companion.load(YamlConfig.kt:56)
            at io.gitlab.arturbosch.detekt.cli.ConfigurationsKt.parsePathConfig(Configurations.kt:67)
            at io.gitlab.arturbosch.detekt.cli.ConfigurationsKt.loadConfiguration(Configurations.kt:29)
            at io.gitlab.arturbosch.detekt.cli.runners.Runner.createSettings(Runner.kt:78)
            at io.gitlab.arturbosch.detekt.cli.runners.Runner.execute(Runner.kt:30)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at io.gitlab.arturbosch.detekt.invoke.DefaultCliInvoker.invokeCli(DetektInvoker.kt:51)
            ... 98 more
    a
    • 2
    • 3
  • m

    mokkun

    04/08/2020, 4:19 AM
    Need a hand with custom reports on Detekt 🙏 [thread]
    a
    • 2
    • 9
  • g

    GurpreetSK

    04/09/2020, 6:44 AM
    Hey! Is it possible to run detekt only on a given set of files? (something like 
    ./gradlew detekt {list of files}
    ) Context: I want to write a git hook which runs detekt on all the changed files (only the changed files) and fail if the task fails.
    d
    a
    s
    • 4
    • 8
  • g

    Gopal S Akshintala

    04/11/2020, 12:35 PM
    Hi! is it possible to get McCabe complexity (mcc) break-up per file/class?
    a
    • 2
    • 2
  • a

    Artur Bosch

    04/11/2020, 6:48 PM
    Edit: repository is still located at arturbosch/detekt and the website at https://arturbosch.github.io/detekt. It is currently not possible to move the repo to the detekt organization as we generate our documentation from the source code and GitHub pages requires us to open a new repo for the url detekt.github.io.
    👍 1
    ❤️ 1
    👌 1
    g
    • 2
    • 5
  • a

    Artur Bosch

    04/12/2020, 10:08 PM
    @Gopal S Akshintala By default sonarqube uses the SonarKotlin profile (Sonar way) without the detekt rules. Have you modified the quality profile or created a new one containing the detekt rules? How many rules do you see in the Rules tab?
    g
    • 2
    • 2
  • f

    fo2rist

    04/13/2020, 6:09 PM
    Can anyone help with configuring console reports? I want to only have the summary (number of issues found) at both success and failures. But when I exclude all processors and reporters I still have all individual issues logged into console Part of config:
    processors:
      active: true
      exclude:
       - 'DetektProgressListener'
       - 'FunctionCountProcessor'
       - 'PropertyCountProcessor'
       - 'ClassCountProcessor'
       - 'PackageCountProcessor'
       - 'KtFileCountProcessor'
    
    console-reports:
      active: true
      exclude:
        - 'ProjectStatisticsReport'
        - 'ComplexityReport'
        - 'FindingsReport'
        - 'NotificationReport'
        - 'BuildFailureReport'
    Example of output:
    a
    • 2
    • 4
  • t

    Thiago Nerys

    04/18/2020, 5:35 AM
    I'm having a hard time trying to make detekt 1.7.0+ work with Spring and java 11. If I go to java 8, it works. If I go to 1.6.0, it works. If I use java 11 and detekt 1.7.0+, sometimes it doesn't load
    java.sql.Date
    , sometimes it can't find
    org.yaml.snakeyaml.nodes.Tag
    . Attached the smallest
    build.gradle.kts
    that I was able to reproduce the problem. Just add an empty .kt file under
    src/main/kotlin
    and you'll see the error. Running gradle 6.3
    build.gradle.kts
    b
    m
    • 3
    • 6
  • d

    dead.fish

    04/21/2020, 8:24 AM
    FYI - the top Github link at https://detekt.github.io/detekt/# still links to
    arturbosch/detekt
    g
    • 2
    • 1
  • d

    dead.fish

    04/21/2020, 3:46 PM
    I have the suspicion that
    detektMain
    cannot run flawless with
    org.gradle.parallel=true
    on many modules at once. I get weird class not found exceptions on runtime (with 1.8) that I don't get with the old (legacy)
    detekt
    task. Has anybody experienced something like this?
    • 1
    • 2
  • s

    sanogueralorenzo

    05/08/2020, 4:28 AM
    Hello everyone, I switched to
    buildUponDefaultConfig = true
    recently and realised that overriden functions also show as
    EmptyFunctionBlock
    (I know there is a flag to ignoreOverriden) I'm more curious to know what was the reasoning behind leaving it to false and what is the best approach to solve situations where you are implementing an interface from the framework or third party provider that you have no control over.
    b
    • 2
    • 2
  • j

    Jukka Siivonen

    05/13/2020, 7:49 AM
    So after updating IDEA plugin I get LongParameterList error for many of my non data type constructors, is this intended behavior? I would expect to get this error only for function parameters
    b
    s
    • 3
    • 12
  • j

    Jukka Siivonen

    05/13/2020, 8:26 AM
    Can't run gradlew detekt because of Could not resolve org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.1. Any ideas? Using Detekt 1.9.0
    g
    • 2
    • 6
  • r

    Rajat Varyani

    05/13/2020, 4:26 PM
    Hi 👋 . I am trying to write to a custom rule to detect mutation in code. This involves checking for presence of Mutable collections, keywords like
    var
    in codebase. What is i could come up till now is
    override fun visitDeclaration(dcl: KtDeclaration) {
            super.visitDeclaration(dcl)
            if (dcl is KtProperty && dcl.isVar) {
                report(CodeSmell(issue, Entity.from(dcl), "Mutation in code"))
            }
        }
    Now I am writing code to detect keywords like
    val list = mutableListOf(1, 2)
    . I am not sure how to go about it?
    b
    • 2
    • 4
  • z

    zmunm

    05/15/2020, 9:06 AM
    1.
    fun foo(bar : (String) -> Unit)
    2.
    fun foo(bar : (name: String) -> Unit)
    Hi. I don't know how can i call
    name
    .. Please give me a keyword lambda property.. lambda description.. anyway If it is
    interface
    , I think it is better to have
    lambda description
    . And when I use this function..
    startSmsUserConsent { name ->
       ...
    }
    I think it is good to specify
    lambda description
    . Is there any rule or plan for this?
    g
    • 2
    • 3
  • k

    kenkyee

    05/16/2020, 12:04 PM
    What do folks do with LongParameterList warnings? I used to recommend that people use a data class to pass paramaters into a constructor or function to group the parameters logically. The current versions of Detekt also flag too many parameters in data class constructors... 😔
    j
    j
    • 3
    • 3
  • s

    schalkms

    05/18/2020, 9:12 PM
    We are happy to merge any doc improvements. 🙂 Feel free to submit a PR.
    🎉 2
    👍 1
    k
    • 2
    • 1
  • b

    Brais Gabin

    05/19/2020, 8:46 AM
    Yes, there’s an issue related with that: https://github.com/detekt/detekt/issues/2655 As a woraround: run
    ./gradlew detektBaseline --continue
    g
    • 2
    • 1
  • c

    Charles

    05/21/2020, 3:20 PM
    Is there a good way to disallow a certain annotation whole-cloth? I am trying to not let people use Java's
    @SuppressWarnings
    in Kotlin code, because we're trying to track warning suppressing and normalizing would help. The problem with this particular annotation is that there is no associated import to filter on at a file level.
    g
    b
    • 3
    • 10
  • g

    gammax

    05/22/2020, 8:48 AM
    I’d love to open an issue about finding a logo for Detekt. Seems like this was never discussed before or am I wrong?
    👏 3
    b
    • 2
    • 1
  • s

    seb

    05/22/2020, 9:00 AM
    I’d love for detekt to get a logo too 🙂 when I google for one (I tend to forget there’s none) I only get the logo for the old Amnesty International’s homonymous tool 🙂
    g
    • 2
    • 1
  • s

    Sourabh Rawat

    05/22/2020, 10:17 AM
    hey getting the following error when I upgraded from 1.6.0 to 1.9.1:
    Caused by: java.lang.NoSuchMethodError: '<http://org.jetbrains.kotlin.com|org.jetbrains.kotlin.com>.intellij.openapi.extensions.ExtensionsArea <http://org.jetbrains.kotlin.com|org.jetbrains.kotlin.com>.intellij.openapi.project.Project.getExtensionArea()'
    please help.
    g
    • 2
    • 2
  • d

    dead.fish

    05/22/2020, 11:01 AM
    Is it somehow possible to place custom detekt rules in
    buildSrc
    instead of a separate Gradle module and let the Gradle plugin pick them up or is this eventually already built-in and I have some configuration error because my custom rules don't seem to execute?
    j
    • 2
    • 1
  • d

    dead.fish

    05/22/2020, 11:03 AM
    I'd like to move my custom Detekt configuration into a Gradle plugin in buildSrc later on, so at this point a
    detektPlugins(project("..."))
    configuration would no longer work anyways...
    j
    a
    • 3
    • 17
Powered by Linen
Title
d

dead.fish

05/22/2020, 11:03 AM
I'd like to move my custom Detekt configuration into a Gradle plugin in buildSrc later on, so at this point a
detektPlugins(project("..."))
configuration would no longer work anyways...
j

Javier

05/22/2020, 11:21 AM
Add this to dependencies block inside build.gradle.kts (buildSrc)
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detekt")
d

dead.fish

05/22/2020, 11:27 AM
Ah, I only applied
detekt-api
there, applying the plugin there should work?! Nice!
No, this didn't work unfortunately 😞 The custom ruleset is not found.
j

Javier

05/22/2020, 11:52 AM
That
implementation
let you use
detektPlugins
in precompiled plugins
For example, this is my own plugin for detekt
It is in buildSrc
And I can apply it to the modules so
The filename for my detekt plugin is Detekt.gradle.kts
d

dead.fish

05/22/2020, 12:14 PM
Hrm... weird, this doesn't look like a standard plugin (that has to be wrapped into a
Plugin<Project>
derived class) at all, but if this works for you, well.
I worked around it for now by using
dependencies {
  val detektPlugins by configurations
  detektPlugins(files("$rootDir/buildSrc/build/libs/buildSrc.jar"))
}
Still haven't moved my Detekt configuration to buildSrc, but only have the additional rules there
j

Javier

05/22/2020, 12:25 PM
It is a precompiled plugin
https://docs.gradle.org/current/userguide/custom_plugins.html#sec:precompiled_plugins
It is easier to use
a

Artur Bosch

05/26/2020, 10:51 AM
Hi, we are doing the same at our repo with precompiled plugins and project dependencies as
detektPlugins
: https://github.com/detekt/detekt/blob/master/buildSrc/src/main/kotlin/detekt.gradle.kts#L45
j

Javier

05/26/2020, 12:04 PM
@Artur Bosch can you take a look to this issue? https://github.com/detekt/detekt/issues/2732
d

dead.fish

06/09/2020, 10:26 AM
@Artur Bosch Sorry for the late reply. Actually, I kind of dislike of having more than
buildSrc
as build configuration source. I see however that Gradle provides no clean way to access the
buildSrc
module itself for this configuration, probably because of https://github.com/gradle/gradle/issues/2531
View count: 15