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

A lot of false-positives and false-negative related with wrong classpath #4253

Closed
BraisGabin opened this issue Nov 9, 2021 · 7 comments · Fixed by #4259
Closed

A lot of false-positives and false-negative related with wrong classpath #4253

BraisGabin opened this issue Nov 9, 2021 · 7 comments · Fixed by #4259

Comments

@BraisGabin
Copy link
Member

It seems that the Kotlin compiler between 1.5.21 and 1.5.31 changed a lot. I'm updating the project where I work from 1.18.1 to 1.19.1-RC1 and I'm getting a lot of false-positives and false-negative in different rules. Some examples:

  • DoubleMutabilityForCollection
  • ImplicitUnitReturnType
  • HasPlatformType
  • MissingWhenCase
  • RedundantSuspendModifier
  • ReplaceSafeCallChainWithRun
  • UnnecessaryLet
  • UnreachableCode
  • UnsafeCast
  • UnusedPrivateMember

I think that all of them are related with the type-solving and problems in the BindingContext that end up creating false positive and negative issues. Until now, in general, this type of problems generated false-negatives. Those are bad, but at least they don't generate noise. But with this release I'm seeing a lot of false-positives too.

@BraisGabin
Copy link
Member Author

🤔 maybe this is not related with the Kotlin compiler at all but something that we did. Checking the logs I see messages like this one:

error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class foo.bar.DataClassName, unresolved supertypes: android.os.Parcelable
    class androidx.core.app.ComponentActivity, unresolved supertypes: android.app.Activity
    class androidx.drawerlayout.widget.DrawerLayout, unresolved supertypes: android.view.ViewGroup
    class androidx.fragment.app.Fragment, unresolved supertypes: android.content.ComponentCallbacks, android.view.View.OnCreateContextMenuListener
    class androidx.recyclerview.widget.RecyclerView, unresolved supertypes: android.view.ViewGroup
    class androidx.appcompat.app.AlertDialog, unresolved supertypes: android.content.DialogInterface
    class androidx.appcompat.app.AppCompatDialog, unresolved supertypes: android.app.Dialog
    class com.chauthai.swipereveallayout.SwipeRevealLayout, unresolved supertypes: android.view.ViewGroup
Adding -Xextended-compiler-checks argument might provide additional information.

Those errors doesn't appears on 1.18.1. I think that in 1.18.1 we were able to resolve types like android.os.Parcelable. That should be in android.jar but for some reason this is broken in 1.19.0-RC1

@cortinico
Copy link
Member

Are you able to bisect in any form?

@BraisGabin
Copy link
Member Author

I think that it should doable using composite build. But I never used them. Probably we should add to our documentation a guide about how to do this. It would help a lot in this cases. Or for a new rule that you write and you want to test it in your project directly.

@BraisGabin
Copy link
Member Author

BraisGabin commented Nov 10, 2021

Using composite builds is way easier than I expected. One point for gradle this time!

It seems that this regression was introduced at 44b7660. @3flex any idea why can this be happening? Maybe the afterEvaluate was needed.

@3flex
Copy link
Member

3flex commented Nov 10, 2021

Thanks for investigating!

I suggest reverting that commit then pushing RC2 to see if this and #4250 are resolved.

Not sure when I'll be able to properly investigate and attempt that change again, but it's clear we need a functional test to ensure correct behaviour.

@eygraber
Copy link
Contributor

eygraber commented Nov 3, 2022

Edit: I saw RC2 but missed the date on this issue. I'm assuming it's not related

I'm getting a lot of false positives for:

UnusedImports // https://github.com/detekt/detekt/issues/5502
RedundantSuspendModifier
UnreachableCode

It seems like all of the false positives are related to either an androidx.core.* import, or something in the function signature coming from an androidx or com.google package.

This only started happening in 1.22.0-RC2 and does not happen in 1.22.0-RC1

@BraisGabin
Copy link
Member Author

Yes, this is a known issue of RC2. We plan to release a RC3 once this issue is fixed.

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

Successfully merging a pull request may close this issue.

4 participants