bumptech / bumptech/glide

Lint check for `Glide.with(view)`

Open
#5,507 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

Hi,

Reading https://github.com/bumptech/glide/issues/898 it seems like (in many cases) `Glide.with(view)` is a potential foot-gun, and it would be better to use `with` passing an activity or fragment.

I've done this refactoring in my own project over in https://github.com/pachli/pachli-android/pull/1519, and as part of that I wrote a Lint detection rule to flag these.

I thought you might want to take this and bundle it as an (ignorable) lint check in Glide (details on publishing custom lint rules in a library project at https://github.com/googlesamples/android-custom-lint-rules).

The relevant parts of that PR are:

- The lint detector, https://github.com/nikclayton/pachli-android/blob/glide-cleanup/checks/src/main/java/app/pachli/lint/checks/GlideWithViewDetector.kt
- One test case, https://github.com/nikclayton/pachli-android/blob/glide-cleanup/checks/src/test/java/app/pachli/lint/checks/GlideWithViewDetectorTest.kt

You can also copy the entire lint machinery from https://github.com/nikclayton/pachli-android/tree/glide-cleanup/checks and delete the files not relevant to the project.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.