slackhq / slack-lints

A collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.
Apache License 2.0
228 stars 13 forks source link

False positive on DeprecatedCall for WebView constructor #268

Open edenman opened 5 months ago

edenman commented 5 months ago

As far as I can tell, WebView is not actually deprecated, but slack-lint is claiming that it is. Maybe something wrong with the annotation detector?

Lint found 6 errors, 0 warnings (10 errors filtered by baseline lint-baseline.xml). First failure:

/Users/edenman/workspace/doggifs/src/main/java/org/coffeetrain/doggifs/SetAvailableGifsScreenView.kt:23: Error: android.webkit.WebView.WebView is deprecated; consider using an alternative. [DeprecatedCall from slack-lint]
    val foo = WebView(context).apply {

Repro project: https://github.com/edenman/doggifs/compare/edenman/webview-deprecated?expand=1

edenman commented 5 months ago

Maybe it's confused because there is a different constructor that is deprecated?

@Deprecated
    public WebView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr,
            boolean privateBrowsing)
ZacSweers commented 5 months ago

ah, thanks for the report. Maybe we're not resolving the correct constructor from the callsite

edenman commented 4 months ago

Also getting similar stuff in media3

Error: androidx.media3.common.MediaItem.fromUri is deprecated; consider using an alternative. [DeprecatedCall from slack-lint]
            HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(newVariant.url))
                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We're using latest on both: media3 1.3.1 and slack lint 0.7.3