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

    Qracle

    12/30/2019, 3:15 AM
    Hi, does anyone use the detekt step in bitrise? I’m not sure how long it would take to finish that step but is 10-15 minutes to complete normal? Thanks
    a
    • 2
    • 1
  • k

    ken

    12/31/2019, 9:02 AM
    anyone got detekt sample project in github?
    b
    a
    • 3
    • 2
  • k

    kenkyee

    01/02/2020, 6:28 PM
    "are now configured to exclude the
    **/test/**,**/*Test.kt,**/*Spec.kt"
    folder (this is valid only if you were using the default config file)" ahh...FWIW, it was nicer having the excludes in one place since now it means you need to duplicate the excludes glob match list in a bunch of places. We did it for comments and these: - 'NamingRules' - 'WildcardImport' - 'MagicNumber' - 'MaxLineLength' - 'LateinitUsage' - 'StringLiteralDuplication' - 'SpreadOperator' - 'TooManyFunctions' - 'ForEachOnRange' - 'FunctionMaxLength' Looks like the default only does comments and: StringLiteralDuplication and TooManyFunctions
    a
    t
    • 3
    • 4
  • k

    kpgalligan

    01/02/2020, 9:40 PM
    Anybody use detekt with multiplatform? Specifically trying custom extensions. I can add my jar at the root level, but in the source set dependencies, the gradle build fails to see
    detektPlugins
    as a valid configuration
    a
    • 2
    • 2
  • k

    kenkyee

    01/03/2020, 10:10 PM
    Does turning on debug mode also print out the baseline file? I don't see it in the debug output. I can't get detekt to take my baseline file which it definitely generates if I do "gradle detektBaseline"
    Untitled
    • 1
    • 1
  • b

    bbaldino

    01/07/2020, 10:04 PM
    Is there any rule that would allow enforcing a return value (from a function marked with an annotation) wasn't ignored?
    a
    d
    s
    • 4
    • 31
  • a

    Artur Bosch

    01/12/2020, 5:57 PM
    Just found out that detekt is on "Trial" at the newest Thoughworks Technology Radar! - https://www.thoughtworks.com/radar/tools We've climbed from Assess to Trial in half a year and they have a nice text written about detekt too. Motivating!
    ❤️ 2
    🎉 6
    m
    • 2
    • 1
  • b

    brent

    01/14/2020, 7:11 PM
    I setup detekt a while back and am trying to update from
    1.0.0-RC146
    to
    1.4.0
    . Mostly working, but many of the rules simply aren't running. Looking through GH issues I see work was done around "type resolution" in v
    1.1
    . Is this working on multi-module Android projects yet? I see this comment from back in October with no corresponding PRs since: https://github.com/arturbosch/detekt/issues/2036#issuecomment-544105669
    a
    s
    • 3
    • 19
  • b

    bbaldino

    01/21/2020, 5:45 AM
    Is there a way in a detekt spec (for a rule I'm working on) to use
    ${...}
    in the compiled test code? If I do:
    val code = """
        fun foo() {
            println("The list is ${listOf(1, 2, 3)}"
        }
    """.trimIndent()
    assertThat(subject.compileAndLintWithContext(wrapper.env, code)).hasSize(0)
    then the compiled
    ktFile
    has the list expanded, but if I do:
    val code = """
        fun foo() {
            println("The list is \$\{listOf(1, 2, 3)\}"
        }
    """.trimIndent()
    assertThat(subject.compileAndLintWithContext(wrapper.env, code)).hasSize(0)
    then the compiled
    ktFile
    maintains the escape characters, so the code isn't actually doing the expansion
    s
    a
    c
    • 4
    • 12
  • e

    enighma

    01/24/2020, 11:08 PM
    Hello, I'm using https://github.com/JetBrains/intellij-community/tree/master/uast to parse some kotlin files. From what I understand detekt relies on this library as well? If not feel free to ignore my question. My problem is trying to figure out how I can resolve the value of a reference. In my case it's a `KtNameReferenceExpression`which simply points to a string declared in the same file.
    BindingContextUtils
    seems to provide the functionality I'm after, but I can't figure out how to get a
    BindingContext.
    s
    a
    • 3
    • 4
  • s

    seb

    01/28/2020, 8:37 AM
    You can refer to a very large amount of open source projects out there that are using Detekt, no need to make sample projects.
    n
    • 2
    • 1
  • w

    Will Hawkins

    02/03/2020, 9:40 PM
    Is there a reasonable way to emit a warning from a custom detekt rule?
    g
    • 2
    • 17
  • w

    Will Hawkins

    02/03/2020, 9:45 PM
    A related question, perhaps: Where is the best place to put a check on the user-specified configuration for a particular custom ruleset?
    s
    a
    • 3
    • 11
  • c

    Cody Engel

    02/04/2020, 7:14 PM
    Is there a good way to reuse exclude patterns with detekt? I’ve found it’s a lot of copy/paste of
    excludes: "**/*Test.kt"
    https://arturbosch.github.io/detekt/howto-migratetestpattern.html
    ➕ 1
    g
    m
    • 3
    • 4
  • z

    zmoore

    02/13/2020, 7:01 AM
    Are there plans to add android configurations to Lint rule sets outside of the formatting group? i.e. Empty blocks are valid in android https://developer.android.com/kotlin/style-guide#empty_blocks as long as they are on a new line. A global variable for this configuration option could be useful
    b
    s
    • 3
    • 2
  • h

    Hardik Trivedi

    02/16/2020, 1:41 PM
    If I use plugin for IDE and not gradle plugin, is there a way I can generate the detekt report of violations? Or the only way is to visit each file and correct the errors?
    a
    • 2
    • 3
  • o

    okue

    02/17/2020, 11:05 AM
    Does anyone know when detekt-intellij-plugin 1.0.0-RC1 is released? https://github.com/detekt/detekt-intellij-plugin/milestone/4
    a
    • 2
    • 2
  • l

    Luke

    03/04/2020, 8:58 PM
    I would like some assistance integrating Detekt in my Android project. I successfully generated my config file, but that’s all that is working. Both tasks
    detektBaseline
    and
    detekt
    finish successfully in 1 second and nothing else happens, even though I know for a fact that the code contains errors. The only way I had it working was by creating my own Gradle tasks, but I don’t want to do this if I don’t have to. I have this in my project-level Gradle:
    plugins {
        id "io.gitlab.arturbosch.detekt" version "1.6.0"
    }
    
    detekt {
        toolVersion = "1.6.0"
    
        config = files("$projectDir/config/detekt/detekt.yml")
        baseline = file("$projectDir/config/detekt/baseline.xml")
    //    source = files("src/main/kotlin") // This does not work for some reasons (Could not set unknown property 'source' for object of type io.gitlab.arturbosch.detekt.extensions.DetektExtension.)
    
        buildUponDefaultConfig = true
        parallel = true
        ignoreFailures = true
    
        reports {
            txt.enabled = false
            xml.enabled = false
            html {
                enabled = true
                destination = file("$projectDir/reports/detekt/report.html")
            }
        }
    }
    s
    r
    c
    • 4
    • 7
  • r

    r4zzz4k

    03/05/2020, 2:51 PM
    Hey. I've looked through existing rules, seems that nothing covers number of parameters in contructors.
    LongParameterList
    is the nearest thing, but it covers only methods. I've tried to cover constructors there (https://github.com/r4zzz4k/detekt/commit/1cf853c), but
    ./gradlew check
    finds issues with existing code after that (https://github.com/arturbosch/detekt/blob/521e968/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/CodeSmell.kt#L44-L51). So two questions: 1. Does this sound like a useful rule? In discussions over the Internet on argument count limit I mostly see costructors included. Checktyle, for example, also covers both methods and parameters (https://checkstyle.sourceforge.io/apidocs/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheck.html), PMD seems to agree on that (https://stackoverflow.com/q/56492868/2475207). 2. What's the flow for contributing rules which don't validate current code? Seems that
    check
    task completes successfully on the project itself. 3. Are there any general contribution guidelines described somewhere I've missed?
    b
    • 2
    • 3
  • r

    r4zzz4k

    03/05/2020, 2:53 PM
    I'm also occasionally catching the following when trying to run
    ./gradlew check
    on my local branch:
    Execution failed for task ':detekt-api:detekt'.
    > io.gitlab.arturbosch.detekt.api.RuleSetProvider: Error reading configuration file
    ...
    Caused by: java.util.ServiceConfigurationError: io.gitlab.arturbosch.detekt.api.RuleSetProvider: Error reading configuration file
            at io.gitlab.arturbosch.detekt.core.RuleSetLocator.load(RuleSetLocator.kt:29)
            at io.gitlab.arturbosch.detekt.cli.config.DefaultPropertiesConfigValidator$validate$1.invoke(DefaultPropertiesConfigValidator.kt:20)
            at io.gitlab.arturbosch.detekt.cli.config.DefaultPropertiesConfigValidator.validate(DefaultPropertiesConfigValidator.kt:27)
            at io.gitlab.arturbosch.detekt.cli.config.ConfigValidatorsKt.checkConfiguration(ConfigValidators.kt:18)
            at io.gitlab.arturbosch.detekt.cli.runners.Runner.execute(Runner.kt:30)
            at io.gitlab.arturbosch.detekt.invoke.DefaultCliInvoker.invokeCli(DetektInvoker.kt:51)
            ... 93 more
    Caused by: java.util.zip.ZipException: invalid distance too far back
            ... 99 more
    Not sure if I'm doing something wrong or this is an issue to be reported. Just in case this helps: Ubuntu 19.10,
    > java -version
    openjdk version "1.8.0_242"
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
    OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
    b
    • 2
    • 2
  • c

    chao

    03/15/2020, 8:21 PM
    I guess the question is how to run the tests using intelliJ. I installed the Spek plugin already and still couldn’t find the spec
    b
    s
    • 3
    • 5
  • b

    Bryan Lindsey

    03/16/2020, 5:27 PM
    I just found a line on this page (https://arturbosch.github.io/detekt/howto-buildupondefaultconfig.html) that seems to have some more info:
    Make sure to specify the 
    input
     parameter or no sources are found and detekt won’t run!
    This seems to be partially true. It does seem to run if you don't have a separate config YAML file. I updated the input as per that page and it works well enough for now. Still confusing that it can run without it in some scenarios.
    s
    • 2
    • 6
  • z

    zmoore

    03/19/2020, 10:17 PM
    Is it currently possible to extend a config that is not the base config? Would this be something we would be interested in in the library?
    c
    s
    a
    • 4
    • 9
  • m

    Michael Friend

    03/20/2020, 1:09 PM
    When i generate a baseline through gradle, I keep getting lines like
    <ID>NoBlankLineBeforeRbrace:</ID>
    without a reference to a part of the codebase. This seems to cause detekt to ignore the rule entirely in that module rather than just ignore existing instances of violations. Is this expected behavior and is there any way to prevent this from being generated?
    b
    s
    • 3
    • 5
  • j

    Joe

    03/24/2020, 1:15 AM
    I'm getting the following exception with detekt 1.7.0 when using
    --config-resource detekt-config.yml
    to read a config file out of a jar on the classpath. running detekt via maven antrun plugin. works fine in 1.6.0. anyone else seen anything like this?
    java.nio.file.FileSystemNotFoundException
    	at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:169)
    	at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:155)
    	at java.base/java.nio.file.Path.of(Path.java:208)
    	at java.base/java.nio.file.Paths.get(Paths.java:97)
    	at io.gitlab.arturbosch.detekt.rules.documentation.LicenceHeaderLoaderExtension.init(LicenceHeaderLoaderExtension.kt:27)
    	at io.gitlab.arturbosch.detekt.core.FileProcessorLocator.load(FileProcessorLocator.kt:18)
    	at io.gitlab.arturbosch.detekt.core.DetektFacade$Companion.create(DetektFacade.kt:90)
    	at io.gitlab.arturbosch.detekt.cli.runners.Runner.execute(Runner.kt:33)
    	at io.gitlab.arturbosch.detekt.cli.Main.main(Main.kt:20)
    b
    • 2
    • 2
  • g

    gammax

    03/25/2020, 4:32 PM
    I’m looking for an easy way to report warnings in Detekt (that are not going to fail the build). I know there is a
    Severity.Warning
    on the
    Issue
    class that I can set for each issue that I report on a my rule. The problem is that those issues are counted towards the total number of issues used to let Detekt fail or not. Anyone faced a similar scenario?
    s
    t
    a
    • 4
    • 11
  • s

    sanogueralorenzo

    03/29/2020, 3:04 AM
    Hello everyone, does the detekt cli have any advantage over the gradle plugin? Can you do top level task instead of 1 per module as well?
    t
    • 2
    • 4
  • s

    sanogueralorenzo

    03/31/2020, 4:55 AM
    Looking at the CLI again I was wondering how do you download/generate the latest detekt-formatting jar? Would it be possible to include it in future releases?
    a
    • 2
    • 1
  • s

    seb

    03/31/2020, 1:57 PM
    Known issues or new ones? If they’re new ones, file them please 🙂
    d
    • 2
    • 1
  • g

    gammax

    03/31/2020, 2:10 PM
    IIRC we don’t have a list of rules that rely on type resolution. As a rule of thumb, if they contain this line:
    if (bindingContext == BindingContext.EMPTY) return
    in the body of the rule source code, they need type resolutions to work. They will be skipped otherwise.
    d
    • 2
    • 2
Powered by Linen
Title
g

gammax

03/31/2020, 2:10 PM
IIRC we don’t have a list of rules that rely on type resolution. As a rule of thumb, if they contain this line:
if (bindingContext == BindingContext.EMPTY) return
in the body of the rule source code, they need type resolutions to work. They will be skipped otherwise.
d

dead.fish

03/31/2020, 2:19 PM
Ok, seems to mention 11 rules so far, unfortunately rather interesting ones... https://github.com/arturbosch/detekt/search?q=%22if+%28bindingContext+%3D%3D+BindingContext.EMPTY%29+return%22&amp;unscoped_q=%22if+%28bindingContext+%3D%3D+BindingContext.EMPTY%29+return%22
This is quite new, isn't it? I vaguely remember that there was once an implementation of these rules that didn't need any special setup. But then again, I might have been used my own Gradle tasks back in the day.
View count: 5