Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detekt 1.22.0-RC1 -> 1.22.0-RC2 breaks UnreachableCode #5435

jeffdcamp opened this issue Oct 17, 2022 · 1 comment · Fixed by #5508

Detekt 1.22.0-RC1 -> 1.22.0-RC2 breaks UnreachableCode #5435

jeffdcamp opened this issue Oct 17, 2022 · 1 comment · Fixed by #5508


Copy link

After updating from Detekt 1.22.0-RC1 to 1.22.0-RC2 invalid UnreachableCode violations are showing

Expected Behavior

Code called from external libraries should not cause UnreachableCode

Observed Behavior

Any code called from an external library in an ?: operator causes UnreachableCode

Steps to Reproduce

Run ./gradlew detektDebug

Test.kt:13:9: This expression is unreachable code which should either be used or removed. [UnreachableCode]

Sample Code (Failing code on line 11, Workaround code on line 12)

package org.test


class Test {
    fun testBug() {

    private fun getLastPathSegment(uriText: String) {
        val uri = uriText.toUri() // causes UnreachableCode.... code ref in core-ktx-1.5.0.jar: public inline fun String.toUri(): Uri = Uri.parse(this))
//        val uri = Uri.parse(uriText) // does NOT cause UnreachableCode (copied code from core-ktx-1.5.0.jar)
        val lastPath = uri.lastPathSegment ?: return

Your Environment

Seen this same issue in many projects on different dev environments

Copy link

I have two theories here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

3 participants