Add a lint rule to detect unused formatted resources - #716
Merged
Conversation
theisenp
force-pushed
the
unused-formatted-resource-lint
branch
from
July 2, 2026 19:06
e13ed1b to
5e69760
Compare
JakeWharton
reviewed
Jul 2, 2026
theisenp
force-pushed
the
unused-formatted-resource-lint
branch
2 times, most recently
from
July 2, 2026 19:38
ef8ba1f to
08fdaa5
Compare
theisenp
marked this pull request as ready for review
July 2, 2026 19:38
eric-labelle
approved these changes
Jul 3, 2026
theisenp
force-pushed
the
unused-formatted-resource-lint
branch
from
July 6, 2026 18:11
08fdaa5 to
2845493
Compare
theisenp
force-pushed
the
unused-formatted-resource-lint
branch
from
July 31, 2026 21:09
2845493 to
c2a52eb
Compare
theisenp
force-pushed
the
unused-formatted-resource-lint
branch
from
July 31, 2026 23:27
c2a52eb to
fe4a53e
Compare
theisenp
enabled auto-merge
July 31, 2026 23:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #649 we changed the way Paraphrase generates
FormattedResources, so that instead of generating a reference to all strings with ICU arguments, it generates a reference to all strings full stop. That helps catch some correctness issues, but it also exacerbated a quirk in the way that Paraphrase interacts with lint.Paraphrase breaks the standard Android
UnusedResourceslint in a couple ways:checkGeneratedSourcesis disabled, lint reports false positives because it doesn't see resource references in the generatedFormattedResourcesobject.checkGeneratedSourcesis enabled, lint reports false negatives because every resource is technically referenced in the generatedFormattedResourcesobject.I'm proposing a new
UnusedFormattedResourceslint rule to address the problem. Basically it's a version ofUnusedResourcesthat's Paraphrase-aware:FormattedResourcesas a usage of the underlying stringFormattedResourcesitself as sufficient to mark a string as usedI'm sure this implementation is missing some nuances, but it at least seems work when I locally apply it to Cash App, so I think it's a reasonable starting point, and we can iterate as issues arise.