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

Resources used via Paraphrase are flagged as unused by lint #159

Open
theisenp opened this issue Apr 28, 2023 · 2 comments
Open

Resources used via Paraphrase are flagged as unused by lint #159

theisenp opened this issue Apr 28, 2023 · 2 comments

Comments

@theisenp
Copy link
Collaborator

If you're using Paraphrase then you may never reference a formatted string resource directly in your Kotlin code - you do it indirectly through the generated Paraphrase code. UnusedResourceDetector doesn't seem to pick up those indirect references, so it reports UnusedResources lint errors.

On one hand, a reference in the generated Paraphrase shouldn't automatically mark a resource is used. If the Paraphrase function is never called then the resource really is unused. But if the Paraphrase function is called, that would ideally be enough to satisfy lint.

I haven't looked into how UnusedResourceDetector works, so I'm not sure what options we have to mitigate this.

@JakeWharton
Copy link
Collaborator

This came up a lot with Butter Knife where resource references would only exist in the generated code. I had good success reporting these to Google. It's a little different because it's annotation processor-generated code vs Gradle plugin-generated code, but it simply may be Lint isn't running over the code generated by the mechanism we're using.

@JakeWharton
Copy link
Collaborator

Actually as soon as I hit send I also remember this coming up when building view binding. I don't recall the outcome of that, though. Lint has a full call graph analysis framework so it should be able to trace unused functions to unused resource references.

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

No branches or pull requests

2 participants