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
  • v

    Vivek Krishnan

    04/19/2021, 8:47 AM
    import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
    import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
    import org.springframework.boot.gradle.plugin.SpringBootPlugin
    import org.springframework.boot.gradle.tasks.run.BootRun
    
    plugins {
        base
        id("com.dorongold.task-tree") version "1.4"
        id("org.springframework.boot") version "2.4.1" apply false
        kotlin("jvm") version "1.4.21"
        kotlin("plugin.spring") version "1.4.21" apply false
        id("org.sonarqube") version "3.1.1"
        idea
        jacoco
        id("io.gitlab.arturbosch.detekt") version "1.16.0" apply true
    }
    
    group = "com.abc.engine"
    
    allprojects {
        val runningOnGitlabCI = System.getenv("GITLAB_CI")?.toBoolean() == true
    
        version = when {
            runningOnGitlabCI -> System.getenv("CI_COMMIT_TAG") ?: System.getenv("CI_PIPELINE_ID") ?: "ci_undefined"
            else -> "undefined"
        }
    
        repositories {
            mavenCentral()
            maven(url = "<https://oss.jfrog.org/artifactory/oss-snapshot-local/>")
            jcenter()
        }
    }
    
    val SRC_ENCODING = "UTF-8"
    val SRC_VERSION = 11
    
    idea {
        project {
            jdkName = "$SRC_VERSION"
            languageLevel = IdeaLanguageLevel("$SRC_VERSION")
            vcs = "Git"
        }
    
        module {
            excludeDirs = excludeDirs + file(".gradle/")
        }
    }
    
    subprojects {
        apply(plugin = "kotlin")
        apply(plugin = "jacoco")
        apply(plugin = "detek")
    
    //    tasks.register()
    
    //    tasks.register("detektAll", io.gitlab.arturbosch.detekt.Detekt) {
    //        def autoFix = project.hasProperty('detektAutoFix')
    //
    //        description = "Custom DETEKT build for all modules"
    //        parallel = true
    //        ignoreFailures = false
    //        autoCorrect = autoFix
    //        buildUponDefaultConfig = true
    //        setSource(projectSource)
    //        baseline.set(baselineFile)
    //        config.setFrom(configFile)
    //        include(kotlinFiles)
    //        exclude(resourceFiles, buildFiles)
    //        reports {
    //            html.enabled = true
    //            xml.enabled = false
    //            txt.enabled = false
    //        }
    //    }
    
    //    tasks.register("detektGenerateBaseline", io.gitlab.arturbosch.detekt.DetektCreateBaselineTask) {
    //        description = "Custom DETEKT build to build baseline for all modules"
    //        parallel = true
    //        ignoreFailures = false
    //        buildUponDefaultConfig = true
    //        setSource(projectSource)
    //        baseline.set(baselineFile)
    //        config.setFrom(configFile)
    //        include(kotlinFiles)
    //        exclude(resourceFiles, buildFiles)
    //    }
    
        tasks.withType<Test>().configureEach {
            useJUnitPlatform()
            testLogging {
                events("failed")
            }
            maxParallelForks = Runtime.getRuntime().availableProcessors()
    
        }
    
        tasks.withType<KotlinCompile>().configureEach {
            kotlinOptions {
                jvmTarget = "11"
                kotlinOptions.useIR = true
            }
        }
    
        tasks.withType<BootRun>().configureEach {
            val profiles = System.getenv("SPRING_PROFILES_ACTIVE")
            if (profiles == null || profiles.trim() == "") {
                val springProfilesActive = project.gradle.startParameter.systemPropertiesArgs["spring.profiles.active"]
                        ?: "localdev"
                args = ((args ?: emptyList()) + "--spring.profiles.active=$springProfilesActive")
            }
            jvmArgs = listOf("-Xmx512m")
        }
    
        tasks.check {
            finalizedBy(tasks.jacocoTestReport)
        }
    
        tasks.jacocoTestReport {
            dependsOn(tasks.test)
            reports {
                xml.isEnabled = true
                csv.isEnabled = false
                html.isEnabled = false
            }
        }
    
        // global dependencies configuration
        dependencies {
            "annotationProcessor"(platform(SpringBootPlugin.BOM_COORDINATES))
    
            "implementation"(platform(SpringBootPlugin.BOM_COORDINATES))
            "implementation"(enforcedPlatform("com.amazonaws:aws-java-sdk-bom:1.11.862")) // amazon v1 bom
            "implementation"(enforcedPlatform("software.amazon.awssdk:bom:2.14.19")) // amazon v2 bom
            "implementation"(kotlin("stdlib"))
            "implementation"(kotlin("reflect"))
    
            "compileOnly"(platform(SpringBootPlugin.BOM_COORDINATES))
            "compileOnly"("org.springframework.boot:spring-boot-configuration-processor")
    
            "testImplementation"(platform(SpringBootPlugin.BOM_COORDINATES))
            "testImplementation"("org.junit.jupiter:junit-jupiter-api")
            "testImplementation"("org.junit.jupiter:junit-jupiter-params")
    
            "testRuntimeOnly"(platform(SpringBootPlugin.BOM_COORDINATES))
            "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine")
    //        "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.16.0")
        }
    }
    g
    6 replies · 2 participants
  • s

    Sebastian Kaspari

    04/27/2021, 8:10 AM
    Is anyone already looking into updating
    kotlinx-html-jvm
    to
    0.7.3
    which made it to Maven Central?
    🎉 2
    g
    2 replies · 2 participants
  • j

    Jakub Chrzanowski

    04/28/2021, 8:16 AM
    Hi folks! Is there any plan for releasing i.e.
    1.16.1
    with https://github.com/detekt/detekt/pull/3455 ?
    g
    2 replies · 2 participants
  • g

    gammax

    05/01/2021, 9:08 AM
    :android-wave: Detekt
    1.17.0-RC1
    is out: https://github.com/detekt/detekt/releases/tag/v1.17.0-RC1 Please test it and report issues if you find any 🙏
    🎉 7
    c
    w
    +1
    5 replies · 4 participants
  • c

    chao

    05/15/2021, 11:00 PM
    Detekt 1.17.0 is published 🎉 https://github.com/detekt/detekt/releases/tag/v1.17.0
    🎉 12
    o
    4 replies · 2 participants
  • m

    mkrussel

    05/25/2021, 9:08 PM
    How would you create a gradle task to run all the detekt targets. I tried.
    val detektAll = tasks.register("detektAll") {
        dependsOn(tasks.withType<io.gitlab.arturbosch.detekt.Detekt>())
    }
    s
    j
    9 replies · 3 participants
  • i

    iamthevoid

    05/26/2021, 6:52 AM
    What is the best way to add rule into configuration file to exclude annotated (with certain annotation) functions from check?
    c
    5 replies · 2 participants
  • i

    iamthevoid

    05/26/2021, 7:17 AM
    What actually
    ArgumentListWrapping
    checks?
    g
    7 replies · 2 participants
  • i

    iamthevoid

    05/27/2021, 10:02 AM
    I use git submodule inside project, both submodule and module has configured detekt. Can i somehow pass baseline and config path depends on module, that detect check at the time?
    g
    24 replies · 2 participants
  • m

    Michael Marshall

    06/07/2021, 2:02 AM
    I've got a custom detekt rule with type resolution and I'm receiving the
    bindingContext
    okay, but
    getType
    is always
    null
    . What should I be doing to get the class of the object declaration?
    override fun visitObjectDeclaration(declaration: KtObjectDeclaration) {
        super.visitObjectDeclaration(declaration)
    
        if (bindingContext == BindingContext.EMPTY) return
    
        if (bindingContext.getType(declaration) is Serializable) {
            report(
                CodeSmell(
                    issue = issue,
                    entity = Entity.from(declaration),
                    message = "Do not use Java Serialization for Kotlin objects."
                )
            )
        }
    }
    g
    16 replies · 2 participants
  • p

    Piyush Kukadiya

    06/07/2021, 7:22 AM
    I have written custom rule and trying to integrate it by following this step https://detekt.github.io/detekt/extensions.html#integrate-your-extension-with-the-detekt-cli and i got below output. Question is how can i confirm that entered command or integration is successful. Command used :
    ./detekt-cli --plugins /Users/piyush.kukadiya/projects/sample/lint_rules_detekt/build/libs/lint_rules_detekt.jar
    Thanks
    command line output while Integrating extension with the detekt CLI
    m
    g
    4 replies · 3 participants
  • m

    Michael Marshall

    06/10/2021, 2:29 AM
    Does the detekt plugin for Android Studio work with custom rules, and specifically for rules using type resolution? My rule works when I do
    ./gradlew detektMain
    but I don't see any live errors while coding.
    c
    g
    +1
    14 replies · 4 participants
  • p

    pavlospt

    06/11/2021, 7:38 AM
    Hello friends 🙂 Wanted to ask when the next version of Detekt is going live. We are getting a lot of errors due to the classloader caching and I see that a fix has been implemented 18 days ago, but still has not made it into a release. Are there any plans to release it soon? Thank you in advance! https://github.com/detekt/detekt/issues/3248
    ➕ 1
    ☝️ 1
    g
    18 replies · 2 participants
  • a

    Ankur Gupta

    06/19/2021, 11:54 AM
    Hi, I'm trying out detekt first time. I want to add additional functionality to it. I want to be able to detect authorship comments at top of file. There is rule for comments
    ForbiddenComment
    but I'm not sure how to customize it to check for the specific type of comments. Or do I need to make a new rule altogether, Please point me to the relevant path. Thanks! Example comment I'm talking about:-
    /**
     * Created by Dev Name on 28/05/21.
     */
    Example 2-
    /*
     * @Author: Dev name
     * Email: <mailto:devname@company.com|devname@company.com>
     */
    g
    3 replies · 2 participants
  • z

    zmunm

    06/22/2021, 1:50 AM
    Hi In detekt idea plugin, operator function constantly raises
    UnusedPrivateMember
    I checked that the relevant content has already been regressed, but how about skipping the operator if there is no type resolution? In idea plugin, false positives seem to have a greater effect than ignore
    c
    g
    5 replies · 3 participants
  • m

    Michael Marshall

    06/23/2021, 6:19 AM
    How can I change the output location of
    detekt-rules.jar
    when I run
    ./gradlew detektMain
    ? The default location is
    detekt-rules/build/libs/detekt-rules.jar
    but I want to move it to somewhere not auto ignored by git
    g
    7 replies · 2 participants
  • b

    brent

    06/25/2021, 1:34 PM
    Any examples of using CLI version of detekt on an Android project with type resolution enabled? I'm able to run without type resolution but once I add the
    --classpath
    param to enable type resolution my execution time goes from a few minutes to ∞ and eventually an OOM crash.
    g
    10 replies · 2 participants
  • g

    gammax

    07/01/2021, 4:50 PM
    Just a small heads up for everyone, we’re having some problems baking the next release (i.e.
    1,18.0-RC1
    ). Specifically we’re waiting for Kotlin
    1.5.21
    to be out (or we might have to revert a Kotlin version bump). I hope this is not ideal, but if you really need a new release out please let us know 👍
    👍 1
    b
    2 replies · 2 participants
  • i

    Ivan Pavlov

    07/02/2021, 12:12 PM
    Hi! I'm trying to setup detekt in maven multimodule project without success. I hope there is a person here who already done it and can help. Details are in thread
    g
    j
    4 replies · 3 participants
  • s

    simon.vergauwen

    07/19/2021, 1:37 PM
    Hey everyone 👋, Does anyone know of a complex example configuring KtLint/formatting for Detekt? I’m currently using KtLint only, and am interested on migrating (back) to Detekt and leveraging the KtLint support underneath.
    👀 1
    g
    b
    7 replies · 3 participants
  • j

    Javier

    07/19/2021, 1:47 PM
    Talking about formatting, @gammax any new about merging your ktfmt Gradle plugin into detekt one?
    👀 1
    g
    4 replies · 2 participants
  • n

    Nick

    07/28/2021, 4:03 PM
    For some reason, my github actions is ignoring my baseline file. Github actions — Android.yml:
    name: Android CI
    
    on:
      # Trigger on every pull request and push to the main branches.
      push:
        branches:
          - "1.0"
          - mo_ql
      pull_request:
      workflow_dispatch:
    
    jobs:
      build:
    
        runs-on: ubuntu-latest
    
        steps:
          - uses: actions/checkout@v2
          - name: set up JDK 11
            uses: actions/setup-java@v2
            with:
              java-version: '11'
              distribution: 'adopt'
          - name: Grant execute permission for gradlew
            run: chmod +x gradlew
          - name: Detekt
            run: ./gradlew detektMain
          - name: Build with Gradle
            run: ./gradlew assemble
    But when I run
    ./gradlew detektMain
    locally, it works fine. The baselines are on Github in the same folders as seen in the screenshot. Also…
    ./gradlew detekt
    runs real quickly, and outputs nothing detekt related. My config is the default generated one. What did I do wrong?
    g
    53 replies · 2 participants
  • k

    Karol Ksionek

    07/29/2021, 10:55 AM
    Hey, I need to ask that question, as it already takes too long for me to solve this. So I’m having an android project with multiple modules and I want to execute detekt for all modules, but skipping ‘build’ and ‘resources’ directories. Hence my configuration
    detekt {
        input = files(escapedProjectDir)
        baseline = file("$escapedRootProjectDir/config/detekt/detekt-baseline.xml")
        config = files("$escapedRootProjectDir/config/detekt/detekt.yml")
        autoCorrect = false
        parallel = true
    }
    
    tasks.withType(io.gitlab.arturbosch.detekt.Detekt) {
        exclude '**/resources/**'
        exclude '**/build/**'
    }
    But it keeps checking build directory. What’s wrong? I’m using detekt 1.18.0-RC2
    g
    22 replies · 2 participants
  • g

    gammax

    08/06/2021, 6:00 PM
    Hello Detekt friends :android-wave: version
    1.18.0-RC3
    was just released: https://github.com/detekt/detekt/releases/tag/v1.18.0-RC3 Please help us test it and report any problems. Ideally we could release a stable next week if nothing major pops up.
    🎉 7
    b
    1 reply · 2 participants
  • j

    Javier

    08/12/2021, 3:44 PM
    detektPlugins doesn’t exist in commonMain dependencies, how can I add my custom rule to there?
    g
    7 replies · 2 participants
  • g

    gammax

    08/12/2021, 6:24 PM
    Yup you spoiled it 😂
    🤗 2
    b
    3 replies · 2 participants
  • r

    robstoll

    08/12/2021, 7:35 PM
    running in the following issue (with detekt 1.18.0) for :detektJvmMain
    error: the feature "multi platform projects" is experimental and should be enabled explicitly
    How do I enable this explicitly could not find something on detekt.github.io
    b
    m
    10 replies · 3 participants
  • r

    robstoll

    08/12/2021, 8:31 PM
    it looks like reporting for MPP is broken as errors are all written to one single file without appending the errors of different plattforms. E.g. if you have an error in js and one in jvm then in the end, main.xml only contains the errors from the jvm platform. Shall I open a bug or do I miss something?
    g
    m
    7 replies · 3 participants
  • r

    robstoll

    08/12/2021, 8:51 PM
    is it correct, that there is no :detektMetadataCommonTest task? I only see detektMetadataCommonMain oh... it's actually detektMetadataMain which does the analysis and not ...CommonMain (what is ...CommonMain for?). In this sense, I would have expected a detektMetadataTest task
    g
    5 replies · 2 participants
  • o

    oshai

    08/15/2021, 2:08 PM
    Hi, does anybody knows
    io.gitlab.arturbosch.detekt
    ?
    g
    6 replies · 2 participants
Powered by Linen
Title
o

oshai

08/15/2021, 2:08 PM
Hi, does anybody knows
io.gitlab.arturbosch.detekt
?
https://plugins.gradle.org/plugin/io.gitlab.arturbosch.detekt
it looks like pointing to older repo but have new versions
g

gammax

08/15/2021, 2:20 PM
That’s the Detekt Gradle Plugin yes
it looks like pointing to older repo
What do you mean?
o

oshai

08/15/2021, 2:48 PM
Thanks, I was confused because https://gitlab.com/arturbosch/detekt is deprecated but looks like it's just the coordinates that were unchanged
g

gammax

08/15/2021, 2:51 PM
yup
View count: 11