https://kotlinlang.org logo
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
  • j

    Jukka Siivonen

    12/02/2021, 10:09 AM
    Does anyone know what is the current state of "Identation" rule? We are using latest IDEA plugin, latest IDEA and Detekt 1.18.1 with Gradle but IDEA formatter does not produce formatting that satiesfies Detekt IDEA plugin. For example Detekt - Indentation: Unexpected indentation (12) (should be \8) and Detekt - Indentation: Missing newline after "("
    g
    m
    • 3
    • 12
  • g

    gammax

    12/02/2021, 3:20 PM
    Hey all :android-wave: Santa is coming earlier this year 🎅 Detekt 1.19.0 just got released 🎁 https://github.com/detekt/detekt/releases/tag/v1.19.0
    🎉 12
    m
    • 2
    • 1
  • i

    iamthevoid

    12/05/2021, 8:19 AM
    I use detekt 1.17.1 . It was added in project through root-gradle-script. I try to move it into precompiled script plugin and all looks correct, but behavior changed 0_o . Looks like my config not used, but used some default kind For example: When i leaved unused import before - i got
    NoUnusedImports
    issue and it autocorrects. Now i get another issue
    UnusedImports
    and these unused imports don't disappear (autocorrecting not working) Or before i got issue when blank lines were in end of file or between class members. Now i got
    BUILD SUCCESSFUL
    in same cases. I though it was wrong paths - but checked - config and baseline path points exactly where i want too. Sources folders also set correctly (when i comment they - i get
    BUILD SUCCESSFUL
    in cases when shouldn't) What do i miss? Config in thread
    b
    • 2
    • 8
  • j

    Javier

    12/15/2021, 2:05 PM
    I checked sonarqube has support for detekt (I want to totally remove the sonar original issues and use detekt reports, or in other words, I want a GUI to see detekt issues + codecoverage via sonarqube. https://docs.sonarqube.org/latest/analysis/external-issues/ In another hand, I have seen there is a sonar-detekt plugin. With the official property is not enough so I need to use this plugin? What are the differences?
    g
    s
    • 3
    • 8
  • d

    dimsuz

    12/15/2021, 5:27 PM
    I have detekt configured in a
    kts
    file like this:
    subprojects {
      apply(plugin = "io.gitlab.arturbosch.detekt")
    
      tasks.withType<io.gitlab.arturbosch.detekt.Detekt>() {
        config.setFrom(files(rootProject.file("detekt-config.yml")))
      }
    }
    And when I run this with either
    detektMain
    or
    detektDebug
    (i.e. with Type Resolution), my detekt-config is not being read, because rules I have disabled are actually used and my custom rule set is not used. But if I run without type resolution:
    detekt
    , then it works and sees the config. Is this a known issue? Detekt is
    1.19.0
    g
    • 2
    • 5
  • d

    dimsuz

    12/15/2021, 6:57 PM
    Judging from source code, detekt currently doesn't support type resolution in KMM commonMain modules. Is there an issue I could track for this feature? Would be awesome to have.
    g
    s
    • 3
    • 6
  • m

    Marcelo Hernandez

    12/15/2021, 8:29 PM
    Is it possible to test custom Detekt rules with type resolution that target Android APIs? For example, I’d like to write a rule that flags when Jetpack Compose’s
    setContent
    function is called directly instead of a custom
    setFooContent { }
    which takes care of theming. However when it comes to testing the rule, how does one include the class path of the Compose environment when the custom rule project is a pure Kotlin library?
    b
    s
    • 3
    • 5
  • i

    iliask

    12/16/2021, 2:23 PM
    Hello everyone, I was wondering: Is it possible to make
    detekt
    (without type resolution at the moment) always run after
    assemble
    tasks automatically, either through a detekt configuration or some gradle magic?
    g
    e
    • 3
    • 14
  • m

    miqbaldc

    12/17/2021, 4:22 AM
    latest
    sonar-kotlin
    only supports for
    sonar 7.9.3
    , is there any supported version for
    sonar 7.9.1
    ?
    g
    • 2
    • 1
  • d

    dimsuz

    12/17/2021, 11:58 AM
    Do I understand correctly that when running with "type resolution", detekt still should find all errors which are present without type resolution? I have a KMM project and when I run
    detekt
    I get
    UseDataClass
    error, but if I run
    detektAndroidDebug
    on the same module, I get a
    BUILD SUCCESSFUL
    .
    b
    e
    • 3
    • 4
  • m

    mkrussel

    12/17/2021, 5:00 PM
    What's the status of multiplatform support with detekt and gradle. I see that it is creating tasks for the iOS platforms, but when I run those tasks no report files are generated. Reports are generated for Android and JVM.
    g
    • 2
    • 4
  • r

    rocketraman

    12/20/2021, 8:31 PM
    Re. multiplatform support I see from the previous message support is in beta -- anyone have any specific examples? • I'm looking to enable detekt across all source sets in a kvision style project: frontendMain, commonMain, backendMain • I'd like to enable the formatter/ktlint plugin for all source sets • I'd like to customize detekt ideally once for all source sets in the entire project • Detekt should run with type support
    👀 1
    g
    • 2
    • 8
  • d

    dimsuz

    12/23/2021, 11:31 AM
    Question to detekt maintainers/contributors. How do you usually debug issues with sample projects, what is the best flow for this? I mean if you presented with a project's zip-file, you unpack it, open detekt's
    master
    in your IDE and then...??? How would you go about attaching debugger to a detekt which is being run on that separate project. Or is it vice versa: you put log-statements in detekt's code, build jar and then run "detekt" task in the sample project?
    g
    b
    • 3
    • 5
  • d

    dimsuz

    12/23/2021, 11:45 AM
    A thought which occurred to me several times: usually at work we run detekt without any reports, as a pre-push activity and also on CI. It would be nice if gradle output of failed rules somehow contained links to the rule descriptions. Or more details about them. When you're a seasoned dev, you already know what "UseDataClass" means, but if you're a junior dev you may not know and you'd have to google for it and it not always leads to docs right away.
    b
    • 2
    • 4
  • b

    Brais Gabin

    12/23/2021, 9:13 PM
    I just want to say that I really like the detekt's community. We are getting lately lots of really good PRs from different people helping in different areas of the project. And that's amaizing! Some times we can be slow merging or a bit "picky" with some topics but I really appreciate all the issues and PRs that the community contributes 🙂
    🎉 5
    ❤️ 2
    b
    • 2
    • 1
  • j

    Javier

    12/24/2021, 12:31 PM
    I searched for
    multiplatform
    in docs and I found nothing. I am just running
    ./gradlew detekt
    (indeed
    ./gradlew build
    ) and I would like to know if just running it in the linux runner is enough or I just run
    detekt
    on every single runner to detect code smells in all targets of all modules. I would like to avoid running specific
    detekt**
    tasks because I am using reusable workflows in all projects and every project can have different targets and I want a modular workflow but not very complex one.
    b
    g
    • 3
    • 10
  • i

    iamthevoid

    12/26/2021, 9:21 PM
    * What went wrong:
    Execution failed for task ':android:app:detekt'.
    > java.lang.IllegalStateException: Analyzing /Users/user/StudioProjects/_work/rt-mlk-mobile-kmm/android/app/src/main/java/ru/rt/mlk/android/infrastructure/connectivity/AndroidConnectivityStatus.kt led to an exception. 
      The original exception message was: java.lang.IllegalArgumentException: Missing extension point: org.jetbrains.kotlin.com.intellij.treeCopyHandler in container org.jetbrains.kotlin.com.intellij.core.CoreApplicationEnvironment$1@14a4044f
      Running detekt '1.19.0' on Java '11.0.11+9' on OS 'Mac OS X'
      If the exception message does not help, please feel free to create an issue on our GitHub page.
    b
    g
    • 3
    • 9
  • h

    hfhbd

    12/31/2021, 2:57 PM
    Hey, I search the docs and didn't found it: Is there any GitHub App to add checks with annotations to a PR, like qodana? virtually a "sonarqube" lite version: https://github.com/JetBrains/qodana-examples/pull/2/checks?check_run_id=1776577456 or https://github.com/JetBrains/qodana-examples/pull/2/files
    b
    s
    • 3
    • 7
  • r

    Rainer Schlonvoigt

    01/10/2022, 10:50 AM
    Hey, i searched the docs for this but either it doesn’t exist or i’m bad at searching… Is there a way to forbid using specific types? Specifically, i want to forbid using
    Set<SomeInterfaceType>
    on public APIs in our project because the Swift interop for it is really bad.
    b
    n
    • 3
    • 4
  • d

    dimsuz

    01/12/2022, 4:47 PM
    Hey all. Is there some built in check to suggest replacing one class/function with another? This has surfaced several times on different projects where classes can have same name, but different package (usually custom version of some class present in some library). In android's Jetpack Compose this will have its uses too, because google advocates using e.g.
    package my.project; fun TextField()
    rather than
    fun MyProjectTextField()
    to differtiate this from built-in
    anrdoidx.compose.material.TextField
    . So I'm about to write some rule which detekts usages of
    com.google.TextField
    and suggests replacing it with
    my.project.TextField
    , same for classes. And I thought maybe I missed some existing rule.
    b
    m
    • 3
    • 10
  • t

    Tim Oltjenbruns

    01/19/2022, 9:04 PM
    Is there a way to customize the order that the ClassOrdering rule enforces? We use companion objects almost exclusively for factory methods, and we want those near the top of our classes next to the constructors. Checking for that order, or at least disabling the ordering rule specifically for companion objects, would be super helpful.
    m
    g
    • 3
    • 4
  • s

    Sebastian Schuberth

    01/21/2022, 6:22 PM
    Ever since I've renamed my GitHub job name to upload detekt's SARIF result, I'm getting "analysis was not found":
    j
    • 2
    • 6
  • d

    davebarda

    01/25/2022, 9:48 PM
    Hey guys, i'm writing a gradle plugin that wraps detekt gradle plugin with some other static code analysis stuff, is there any way to supply some default configuration of my own from the plugin jar?
    j
    • 2
    • 1
  • j

    Janusz Chorko

    02/02/2022, 4:42 PM
    I just noticed that detekt does not analyse sources in kotlin subdirectory of android variant (even with detektVariant2Debug task):
    src
    ├── variant1
    │   └── java
    │       └── files here are processed
    ├── main
    │   └── java
    │       └── files here are processed
    └── variant2
        └── kotlin
            └── files here are ignored
    If I rename sources directory to java it reports issues in those files. I'm not specifying any custom source directories in my build scripts. Does detekt use only java sources instead of kotlin sources? AGP sourceSets task reports java subdir in java sources and both in kotlin sources:
    Java sources: [module1\src\variant2Debug\java]
    Kotlin sources: [module1\src\variant2Debug\kotlin, module1\src\variant2Debug\java]
    b
    g
    • 3
    • 8
  • p

    PJ Walstrom

    02/09/2022, 2:30 PM
    Hello, I was wondering if there are any recommendations on how to use detekt with as little configuration as possible. We are using the gradle-plugin, the idea plugin and try to just use the idea default code style. We don't really care if we are using wildcard imports or not, just as long as everybody are using the same (default) ruleset. When doing "reformat code", we would like all the rulesets to be aligned. Another example is the import ordering. The detekt idea plugin does not report on this, whereas the gradle plugin fails the build
    > Task :detekt FAILED
    formatting - 5min debt
            ImportOrdering - [] at HealthRoutes.kt:3:1
    This is our current config
    g
    k
    • 3
    • 3
  • s

    simon.vergauwen

    02/09/2022, 3:44 PM
    Hey 👋 , I'm writing some Gradle plugins that share a common setup between a bunch of projects, and I'm trying to share the baseline file between all projects as well. Does anyone know how you can add a
    baselline.yml
    to a Gradle plugin? When I add it to
    src/resource
    it's not working correctly 😞 And it seems I cannot configure all properties from the baseline programmatically, or am I looking in the wrong place?
    b
    g
    e
    • 4
    • 15
  • j

    Justin Tullgren

    02/14/2022, 2:47 PM
    Hi, can anyone point me to which
    Rule
    visitor method to override to determine if a type implements an interface? I looked at visitSuperTypeEntry but in poking it I didn't see what i was looking for. Usecase: if a type implements an interface, check the value set to a
    val
    property.
    b
    • 2
    • 3
  • m

    mkrussel

    02/16/2022, 9:51 PM
    I'm trying to write some custom rules, but the IDE cannot complete resolve any of the classes in the
    org.jetbrains.kotlin.psi
    package. Everything compiles but the IDE not finding the classes make it hard to use. Is there something I need to configure to get this working?
    b
    • 2
    • 3
  • e

    Eric

    02/18/2022, 3:27 PM
    Is there a way I can get the detekt plugin version inside another custom task? I’m trying to abstract away some behavior that’s in each of our projects. We download the detekt config from a central location (artifactory) and have a file there for every version, like
    detekt-config-1.15.yml
    and
    detekt-config-1.19.yml
    etc. I’d like my task to just discover the version of detekt and built the URL automatically. I can do something like
    project.extensions.findByName("io.gitlab.arturbosch.detekt")
    to find the plugin, but then how can I introspect that to find the version?
    • 1
    • 3
  • j

    Javi Chaqués

    02/22/2022, 8:17 AM
    Hi, is it possible to apply the plugin with Gradle Version Catalogs?
    b
    • 2
    • 9
Powered by Linen
Title
j

Javi Chaqués

02/22/2022, 8:17 AM
Hi, is it possible to apply the plugin with Gradle Version Catalogs?
b

BorzdeG

02/22/2022, 10:28 AM
plugins {
  alias(libs.plugins.detekt)
}
libs.versions.toml :
[plugins]
detekt = { id = "io.gitlab.arturbosch.detekt", version = "1.19.0" }
☝️ 1
j

Javi Chaqués

02/22/2022, 5:42 PM
And how u declare it in subprojects?
b

BorzdeG

02/22/2022, 6:18 PM
with submodules a little differently sample 1: root module:
plugins {
  alias(libs.plugins.detekt).apply(false)
}

subprojects {
  project.pluginManager.withPlugin(rootProject.libs.plugins.kotlin.jvm.get().pluginId) {
    plugins.apply(rootProject.libs.plugins.detekt.get().pluginId)
    tasks.withType<Detekt> {
      buildUponDefaultConfig = true
      config.from(rootDir.resolve("detekt/detekt.yml"))
    }
  }
}
sample 2: root module:
plugins {
  alias(libs.plugins.detekt).apply(false)
}
submodule:
plugins {
  id(libs.plugins.detekt.get().pluginId)
}
tasks.withType<Detekt> {
  buildUponDefaultConfig = true
  config.from(rootDir.resolve("detekt/detekt.yml"))
}
I prefer the first example…
j

Javi Chaqués

02/22/2022, 6:19 PM
Ty Viktor, i will try tomorrow
Sorry for not bein able to test it earlir.
i'm gettint this error:
Caused by: java.lang.NoClassDefFoundError: com/android/build/gradle/BaseExtension
b

BorzdeG

02/25/2022, 8:38 PM
It seems this is a problem of a different order and is related to the Android project…
View count: 14