https://kotlinlang.org logo
Join Slack
Powered by
# detekt
  • e

    Eugen Martynov

    07/14/2025, 2:02 PM
    Does detekt have for body expression functions that return Unit and have no explicit return type specification?
    ✅ 1
    b
    • 2
    • 11
  • a

    Aditya Bhaskar

    07/14/2025, 5:17 PM
    Hey folks, I'm updating our projects to Kotlin 2.2.0 and detekt appears to be fairly incompatible. I'm getting lots of false
    UnusedPrivateMember
    and
    NullableToStringCall
    errors, and a few ISEs:
    Copy code
    > A failure occurred while executing io.gitlab.arturbosch.detekt.invoke.DetektWorkAction
       > java.lang.IllegalStateException: Analyzing something.kt led to an exception.
         Location: java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
         The original exception message was: java.lang.NullPointerException
         Running detekt '1.23.8' on Java '21.0.6+-13391695-b895.109' on OS 'Mac OS X'
         If the exception message does not help, please feel free to create an issue on our GitHub page.
    Given this PR is still draft, is this to be expected?
    b
    g
    n
    • 4
    • 22
  • r

    Rob

    07/27/2025, 4:34 PM
    Hello All! I've published a ruleset that ensures correct handling of coroutine cancellation in catch blocks. Please try it out and provide feedback. Thanks! https://github.com/zirman/robs-rules/
    K 1
    b
    s
    • 3
    • 14
  • j

    juliocbcotta

    08/05/2025, 2:11 PM
    I am migrating my project o kotlin 2.2.0 and getting lots of false positive... for instance UnusedPrivateMember for
    Copy code
    private fun FSProductToAdd.toOrderPipeModel(): OPProductToAdd {
        return OPProductToAdd(
            productId = productId,
            quantity = quantity
        )
    }
    even thought that is called inside of the class... I also got a bunch of RedundantSuspendModifier
    Copy code
    private suspend fun register() = suspendCoroutine { cont ->
    // do integration with callbacks from tracking library
    }
    also UnreachableCode
    Copy code
    internal fun decodeJwt(token: String): JSONObject? {
        var stringToDecode = (token.split('.').getOrNull(1) ?: return null)
            .replace('-', '+')
            .replace('_', '/')
    
        @Suppress("MagicNumber")
        when (stringToDecode.codePointCount(0, stringToDecode.lastIndex) % 4) {
            2 -> stringToDecode += "=="
            3 -> stringToDecode += '='
            else -> {
                // nothing to do
            }
        }
    
    --> line 32    return try {
            stringToDecode.decodeBase64()?.utf8()?.let(::JSONObject)
        } catch (e: JSONException) {
            Timber.e(e, "Tried to decode a JSON Web Token that is not JSON!")
            null
        }
    }
    saying
    JwtDecoder.kt:32:5: This expression is unreachable code which should either be used or removed. [UnreachableCode]
    ➕ 1
    b
    d
    a
    • 4
    • 5
  • u

    ursus

    08/27/2025, 3:13 PM
    Is there a rule about
    max file lines
    ? (Can't find it) That's something I presonally care more about than number of functions, lines per class etc
    b
    s
    • 3
    • 6
  • s

    segunfamisa

    09/01/2025, 12:33 PM
    hey folks, i notice that detekt baselines don't have any information about the location source of the current issues. I don't know if this was considered in the past and decided against, but I think it could lead to false positives. for example, if I take ForbiddenSuppress rule and I have
    MaximumLineLength
    forbidden and the baseline updated
    Copy code
    @Suppress("MaximumLineLength")
    class Bar
    If for any reason, I have to modify that suppress rule, to something like:
    Copy code
    @Suppress("MaximumLineLength", "RandomOtherRule")
    class Bar
    This entire line is going to be reported despite the fact that a new rule suppression is introduced, and the "already known" issue was not changed
    b
    • 2
    • 6
  • r

    Ryan Ulep

    09/03/2025, 1:01 PM
    Hey all. Question (as I can't find the thread after some searching and scrolling): is there a planned release date for Detekt 2.0? Do we know what features are going to be included (e.g. Kotlin 2+ language support, compiler plugin support, etc)?
    g
    e
    • 3
    • 9
  • s

    seb

    09/04/2025, 5:16 PM
    @gammax looks like auto-fix is broken, at least in the IDE plugin: https://github.com/detekt/detekt-intellij-plugin/issues/533
  • g

    gammax

    09/04/2025, 5:20 PM
    I don’t have much context on the IdE plugin sadly
  • s

    seb

    09/04/2025, 5:36 PM
    I may be one of the biggest contributors lol
    ❤️ 2
  • s

    seb

    09/04/2025, 5:36 PM
    I need to check if the Gradle plugin actually does auto-fix
  • s

    seb

    09/04/2025, 5:36 PM
    Or if the auto-fix mechanism is completely broken
  • s

    seb

    09/04/2025, 6:02 PM
    Looks like setting
    detekt.autoCorrect
    in Gradle also doesn't do auto-correct when I run
    :detekt
    . Is there some other thing I need to do to enable auto-correct for the rule?
    a
    • 2
    • 2
  • e

    eygraber

    09/04/2025, 7:09 PM
    I'm seeing a few instances of this in the logs when running detekt 2.0.0-alpha.0
    There were 11 compiler errors found during legacy compiler analysis. This affects accuracy of reporting.
    Do I need to use the compiler plugin to resolve those?
    b
    • 2
    • 2
  • g

    gammax

    09/04/2025, 7:10 PM
    Please report an issue for both folks
  • n

    Nicholas Doglio

    09/04/2025, 7:13 PM
    Is there going to be a migration guide? Parsing the changelog now and I think I'm able to find what I need but as more things changes having a central concise list changes to make would be helpful 🙌
    b
    e
    g
    • 4
    • 5
  • g

    Gama11

    09/05/2025, 8:29 AM
    is the alpha only available as a github release for now? can't seem to find it in maven central / gradle plugin portal
    h
    g
    • 3
    • 4
  • g

    Gama11

    09/05/2025, 9:18 AM
    testing the alpha against our project right now. seems to be extremely slow, taking over 15 minutes for some modules already. is there by chance a way to output time spent per rule or something like that to narrow down the reason?
    g
    b
    a
    • 4
    • 9
  • b

    Brais Gabin

    09/05/2025, 10:12 AM
    I'm working on the migration guide. It is still a Draft-PR but maybe it help someone: https://github.com/detekt/detekt/pull/8610 Right now it's only for rule authors. I hope to have something for the users today too. Any feedback is more than welcome.
    ❤️ 3
  • j

    Joe

    09/05/2025, 10:45 PM
    I may be missing something in the migration (changed version, detekt-cli's maven groupId, and Main class package coordinate) but getting this when I try updating to 2.0.0-alpha.0 using antrun maven plugin (looks like there's a 0-all.jar, but not a 0.jar for both of these?):
    Copy code
    Downloading from central: <https://repo.maven.apache.org/maven2/dev/detekt/detekt-kotlin-analysis-api/2.0.0-alpha.0/detekt-kotlin-analysis-api-2.0.0-alpha.0.jar>
    Downloading from central: <https://repo.maven.apache.org/maven2/dev/detekt/detekt-kotlin-analysis-api-standalone/2.0.0-alpha.0/detekt-kotlin-analysis-api-standalone-2.0.0-alpha.0.jar>
     [.... snip reactor summary ...]
    Execution detekt of goal org.apache.maven.plugins:maven-antrun-plugin:3.1.0:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:3.1.0 or one of its dependencies could not be resolved: The following artifacts could not be resolved: dev.detekt:detekt-kotlin-analysis-api:jar:2.0.0-alpha.0 (absent), dev.detekt:detekt-kotlin-analysis-api-standalone:jar:2.0.0-alpha.0 (absent): Could not find artifact dev.detekt:detekt-kotlin-analysis-api:jar:2.0.0-alpha.0 in central (<https://repo.maven.apache.org/maven2>)
    ➕ 1
  • u

    ursus

    09/05/2025, 11:39 PM
    Does the new 2.0 mean that type resolution is always on, i.e. there is distinction between the rules anymore?
    b
    n
    • 3
    • 5
  • r

    Ryan Ulep

    09/08/2025, 1:02 PM
    The new
    detekt-compiler-plugin
    should work with Kotlin 2.+ correct? I'm getting:
    Copy code
    error: there are some plugins incompatible with language version 2.0:
      io.github.detekt.compiler.plugin.DetektCompilerPluginRegistrar
    Please use language version 1.9 or below
    g
    b
    k
    • 4
    • 10
  • u

    ursus

    09/11/2025, 7:41 PM
    How do I create the most light task that has
    type resolution
    enabled? If I run
    detektMain
    I'm getting both debug & release. Is that normal? (and release stuff takes way longer)
    a
    b
    • 3
    • 5
  • u

    ursus

    09/12/2025, 5:13 PM
    I have a sort of DSLy interface with many implementations where
    CognitiveComplexMethod
    blows up. Is there a global way to have implementations of such interface to not be analyzed?
    b
    • 2
    • 2
  • e

    Eduard Boloș

    09/26/2025, 2:09 PM
    Hello! I am giving version 2.0.0-alpha.0 a try, and I ran into a problem caused by what I believe to be how I use
    ReportMergeTask
    . In v1, it looks like the Detekt tasks were created only for the variants that were not being filtered out. But now in v2 they are created for all the variants, but only the ones that are not filtered out are linked to the main task as a dependency. However, that means that the merge task, when configured similar to these docs, it will trigger all the registered tasks, although some of them should ignored. I will post my configuration in the thread below, for more clarity. But the question is: am I supposed to do something differently now?
    • 1
    • 4
  • e

    Eduard Boloș

    09/29/2025, 10:06 AM
    Related to v2 again, I am getting a
    NoSuchMethodError
    error in the unit tests when calling
    lintWithContext
    on a rule (stacktrace in thread 🧵). I think it's something due to dependencies, I updated Kotlin to version 2.2.20, but maybe something is missing. Update: downgrading to Kotlin 2.2.10 seems to have fixed the issue.
    ✅ 1
    • 1
    • 2
  • s

    stuebingerb

    09/30/2025, 11:28 AM
    Hi, currently detekt (1.23.8) fails when running with Java 25. Are there plans to support this, or is there anything I can do except for downgrading my local JVM?
    b
    • 2
    • 3
  • e

    eygraber

    10/05/2025, 7:29 PM
    Is there a schedule for the v2 alphas, or is it milestone based?
    g
    • 2
    • 3
  • m

    MIDI

    10/10/2025, 10:25 AM
    Hi all! I am using the Arrow library at work, and am utilizing the arrow-detekt-rules to catch missing
    bind()
    calls. It works fine when running with Gradle, but IntelliJ does not highlight according to this rule, even though I downloaded the arrow-detekt-rules JAR from Maven Repository, placed it in my home folder and pointed to it in the IntelliJ Detekt Plugin settings. Does anyone have experience with this issue or a thought about what might be wrong? Thanks a lot!
    p
    • 2
    • 2
  • u

    ursus

    10/13/2025, 12:41 PM
    Hey I'm looking at the compatibility table (https://detekt.dev/docs/introduction/compatibility/) I'm at the latest stable
    1.23.8
    and kotlin
    2.2.20
    & agp
    8.13.0
    (basically all latest stable stuff) and everything works fine is this not expected? looking at the table I was expecting too need to use the
    2.0.0-alpha.0
    b
    • 2
    • 3