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

    Artur Bosch

    03/05/2019, 7:39 PM
    Correct me if I'm wrong, KtLint does not have a baseline file you could use the wrapper
    detekt-formatting
    . However auto correcting formatting issue cannot be combined with the baseline ... its all or nothing
    s
    1 reply · 2 participants
  • s

    Scott Dillender

    03/05/2019, 9:47 PM
    Has there been any more work done along the lines of type resolution? Is there a branch with it? (Attempting to do something similar to the PR , but I'm having issues https://github.com/arturbosch/detekt/pull/485/files#diff-b891a4f3964171c1075597dbac3d82d7R22)
    a
    s
    5 replies · 3 participants
  • s

    seb

    03/06/2019, 2:28 PM
    I think Lint uses UAST nowadays, no? It was a massive amount of work for them to migrate to it tho as far as I remember
    1 reply · 1 participant
  • v

    vanniktech

    03/08/2019, 8:57 AM
    Lint works on UAST - yes. I’d rewrite the detekt rules to leverage UAST. We get so many things for free. Gradle Integration / Baseline / nice HTML reports / XML reports / quickfixes / IDE integration / inspection of any file type and so many more things Additionally, Lint does work on Kotlin only projects - https://github.com/vanniktech/kotlin-on-code-quality-tools/tree/master/custom-android-lint-rules - they have their own plugin for that which can be applied to kotlin/java only modules and the same lint rules can be used
    s
    7 replies · 2 participants
  • l

    LeoColman

    03/11/2019, 4:32 PM
    Hello!
    m
    2 replies · 2 participants
  • s

    seb

    03/16/2019, 9:34 AM
    Happy to add it the answer to the docs/migration guidelines if you think it’s worth it
    a
    4 replies · 2 participants
  • g

    GreyhairRedbear

    03/23/2019, 12:48 PM
    Is it possible to import a detekt-config.yml into IntelliJ/Android Studio code style settings in some way?
    j
    m
    6 replies · 3 participants
  • m

    Marvin

    03/29/2019, 4:16 PM
    @Mike thank you, i was looking on the maven repo but i have not paid attention to the version number. Adding jcenter as buildScript dependency works fine for me, but i guess its a bit misleading that the official example does not work So I opened an issue https://github.com/arturbosch/detekt/issues/1568
    m
    2 replies · 2 participants
  • j

    Joe

    04/02/2019, 5:35 PM
    i'm seeing this warning even though I don't have
    failFast
    set in my detekt-config.yml (in RC14 run via maven antrun plugin or via cli manually):
    Using deprecated property 'failFast' in the yaml config. Please migrate to the new '--fail-fast' cli-flag or 'failFast' detekt extension property.
    m
    s
    4 replies · 3 participants
  • s

    Shawn A

    04/04/2019, 1:14 AM
    I am using
    toolVersion = "1.0.0.RC9"
    s
    m
    4 replies · 3 participants
  • s

    sanogueralorenzo

    04/04/2019, 3:29 AM
    Is it possible to hide the output of detekt in terminal if it is all good? I would only like to see the errors.
    Successfully generated HTML report at /home/.../build/reports/detekt/detekt.html
    Successfully generated Checkstyle XML report at /home/.../build/reports/detekt/detekt.xml
    
    detekt finished in 10923 ms.
    .................
    Ruleset: comments
    Ruleset: complexity
    Ruleset: empty-blocks
    Ruleset: exceptions
    Ruleset: naming
    Ruleset: performance
    Ruleset: potential-bugs
    Ruleset: style
    Tried with -q and it didn't work
    m
    2 replies · 2 participants
  • m

    marschwar

    04/05/2019, 10:07 AM
    With regards to the 1.0: I know there was quite a big discussion about it and I did see the Roadmap. Is there any list of specific issues that need to be resolved? What do you think about adding a tag to those issues?
    m
    1 reply · 2 participants
  • r

    Riccardo Montagnin

    04/11/2019, 3:10 PM
    Hello everyone, how do I use a custom report output I've made, inside the
    detekt
    section of Gradle?
    a
    2 replies · 2 participants
  • k

    kotta518

    04/11/2019, 6:26 PM
    Hi, any detekt github samples with html report.
    a
    s
    3 replies · 3 participants
  • j

    Joe

    04/18/2019, 3:47 PM
    Are there alternatives to using the spread (
    *
    ) operator when dynamically building a list to call a varargs method with? or is the detekt
    SpreadOperator
    rule just there to make sure there's awareness of the performance implications of doing so?
    s
    t
    3 replies · 3 participants
  • d

    dector

    05/20/2019, 4:10 PM
    Hi. When I'm running
    ./gradlew detekt
    I see this message: "Using deprecated property 'failFast' in the yaml config. Please migrate to the new '--fail-fast' cli-flag or 'failFast' detekt extension property." However, there is no failFast property declared in yaml config file. Using
    1.0.0-RC14
    .
    m
    p
    2 replies · 3 participants
  • t

    TheDukerChip

    06/04/2019, 1:56 PM
    Hey guys, does anyone knows how to integrate the detekt with the build process. In my case i want to break the build if detekt has found any code smell?
    e
    s
    2 replies · 3 participants
  • ó

    Ólavur Joensen

    06/04/2019, 2:14 PM
    Hi, I am experiencing some trouble running Detekt on one of our Kotlin (JVM) projects through Gradle. I have it configured in Gradle/Groovy with a basic
    detekt {
        toolVersion = "1.0.0-RC14"
        input = files("src/main/kotlin")
        filters = ".*/resources/.*,.*/build/.*"
    }
    I get loads of errors in the console, all with the following message:
    Analyzing '[filename redacted]' led to an exception.
    The original exception message was: java.lang.NoClassDefFoundError: io/gitlab/arturbosch/detekt/rules/LinesOfCodeKt$tokenSequence$1
    Running detekt '1.0.0-RC14' on Java '1.8.0_151-b12' on OS 'Mac OS X'.
    (am running Gradle 5.4.1) What I’ve tried - Building and running Detekt via the CLI - this works fine, and gives me a report (I ran it on the same project that fails via the Gradle). - Switching to version 1.0.0-RC13 via Gradle yields the same errors as with RC14 - Clearing out the gradle caches and
    gradle clean
    does not seem to have any effect - (edit) Running the gradle task inside a Docker container using
    gradle@latest
    image doesn’t help Ideally, I want it to be run via Gradle - does anyone have any pointers as to what may the cause of this issue, or perhaps how I can fix it?
    m
    s
    +1
    15 replies · 4 participants
  • a

    Artur Bosch

    06/08/2019, 11:07 AM
    After #kotliners release! Grab RC15 while its hot - https://bintray.com/arturbosch/code-analysis/detekt/1.0.0-RC15 Happy to take any regressions! Changelog: https://arturbosch.github.io/detekt/changelog-rc.html#rc15 Migration from test-pattern -> https://arturbosch.github.io/detekt/howto-migratetestpattern.html Cli binary -> https://github.com/arturbosch/detekt/releases/tag/1.0.0-RC15
    ♥️ 3
    👍 2
    t
    s
    12 replies · 3 participants
  • t

    TheDukerChip

    06/13/2019, 12:19 PM
    Is there any way to configure
    detekt
    to mark the unused methods as a code smell?
    m
    s
    3 replies · 3 participants
  • t

    TheDukerChip

    06/13/2019, 12:46 PM
    What does
    McCabe complexity
    means in Complexity Report?
    s
    4 replies · 2 participants
  • c

    Casey Brooks

    06/14/2019, 6:04 PM
    Does Detekt analyze Java sources too, or just Kotlin? I’m looking to add static analysis to a mixed Java/Kotlin Android project, and would ideally have one tool for analyzing both
    t
    1 reply · 2 participants
  • t

    Trevor Ackerman

    06/18/2019, 5:03 PM
    Does detekt find code duplication?
    e
    s
    +1
    3 replies · 4 participants
  • m

    Mike

    07/03/2019, 5:51 PM
    Upgrading a project from RC14 to RC16 (although RC15 exhibits same issue). Groovy Gradle DSL. Multi-module project where main has code as well as subprojects. Add Detekt plugin in
    allprojects
    configuration. When it runs, it succeeds on all projects BUT then Detekt fails with this error: Execution failed for task ':detekt'.
    /dev/cbttds/cbttdsshrd-service-base/cbttdsshrd-test/build/reports/detekt/main.xml does not exist
    and using --stacktrace shows the following Caused by: java.lang.IllegalStateException: /dev/cbttds/cbttdsshrd-service-base/cbttdsshrd-test/build/reports/detekt/main.xml does not exist at io.gitlab.arturbosch.detekt.output.XmlReportConsolidationKt.readContent(XmlReportConsolidation.kt:44) at io.gitlab.arturbosch.detekt.output.XmlReportConsolidationKt.mergeXmlReports(XmlReportConsolidation.kt:20) Is this an issue specific to multi-module? It seems like Detekt is attempting to consolidate reports or something similar, but I'm not seeing anything in change log about this. Or is this a Gradle task taking place? Any hints or assistance greatly appreciated.
    s
    a
    +1
    4 replies · 4 participants
  • a

    antsiferov.ivan

    07/04/2019, 11:25 AM
    Hi there! Having issue with upgrading from RC14 to RC16. I’m using ktlint wapper and custom ruleset. After upg version, detekt task started to fail with
    Cannot set value for plugins on detekt task and apply detektPlugins configuration at the same time.
    message. My detekt config block is in attached snippet. Anyone faced that error?
    -.groovy
    a
    2 replies · 2 participants
  • h

    hannesstruss

    07/19/2019, 3:36 PM
    ah! found the fix: https://github.com/arturbosch/detekt/commit/0cd1374ecd3e4ede42f7f4971689d5e597040497 Guess I'll wait for the next release 🙂
    👍 1
    a
    2 replies · 2 participants
  • s

    seb

    08/08/2019, 9:11 PM
    Congrats on the 1.0 release! 🎉 Is there a changelog for 1.0?
    🤘 2
    🎉 6
    👍🏼 1
    s
    1 reply · 2 participants
  • s

    sanogueralorenzo

    08/17/2019, 12:43 AM
    what am I missing? how can I have a centralized baseline for the project?
    a
    6 replies · 2 participants
  • c

    Czar

    08/21/2019, 8:59 AM
    Is there a way to enforce indent tabs instead of spaces? EDIT --- So far my research on the matter shows that there is no way to use tabs with either detekt or ktlint. I get the desire to avoid indent-wars, but this effectively prevents teams with existing code bases and style guides based on tabs to use either detekt or ktlint, or forces them to disable all the relevant rule(set)s and write their own. Plainly that sucks 😞
    m
    s
    +2
    19 replies · 5 participants
  • r

    robstoll

    08/21/2019, 3:17 PM
    is there a way to mark a function as part of a builder so that detekt can recognise if one forgot to end the building process?
    s
    5 replies · 2 participants
Powered by Linen
Title
r

robstoll

08/21/2019, 3:17 PM
is there a way to mark a function as part of a builder so that detekt can recognise if one forgot to end the building process?
s

schalkms

08/21/2019, 7:09 PM
Yes, you could write a custom domain-specific rule for that.
r

robstoll

08/21/2019, 7:14 PM
fair enough, I hoped detekt already has something like @CheckReturnValue
s

schalkms

08/21/2019, 7:44 PM
Nope. JSR 305 describes and provides this feature.
r

robstoll

08/21/2019, 8:54 PM
I figured JSR 305 was not really implemented in the sense of, there is no CheckReturnValue annotation in JDK, no? Maybe I am mistaking, if so, shall I open a feature request on github that detekt supports it as well?
s

schalkms

08/22/2019, 10:15 AM
It's not part of the JDK but a reference implementation exists in one of Google's libraries. It's also part of Findbugs and Error Prone. I don't see a reason to reimplement this, because there is more than one existing solution. We strive to adhere to the DRY principle. The following stackoverflow link gives more information regarding JSR 305. https://stackoverflow.com/questions/2289694/what-is-the-status-of-jsr-305 HTH Markus
View count: 3