Skip to content

feat(lint): flag fui_ string resources that nothing in the module references - #2522

Open
demolaf wants to merge 2 commits into
pre-GAfrom
lint/unreferenced-resource-detector
Open

demolaf wants to merge 2 commits into
pre-GAfrom
lint/unreferenced-resource-detector

Conversation

@demolaf

@demolaf demolaf commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Adds an UnreferencedResource lint check that fails the build on a fui_* string or plurals resource :auth never reads.

Changes

Why a custom check

UnusedResources is silent for a library module because lint cannot see its consumers, and checkDependencies against the demo app would flag nearly every resource.

The policy it encodes

No fui_* resource may be unreferenced within :auth itself. Normally the wrong rule for a library; it holds because the README documents these names as ones an app overrides rather than reads.


Maintainer note: Fixes internal CPRN-488

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new custom Android Lint detector, UnreferencedResourceDetector, designed to identify and flag unused fui_* string and plurals resources within library modules, along with its corresponding unit tests. Feedback on the implementation highlights a performance bottleneck in the XML scanning logic, where visiting every element and attribute and using element.textContent can lead to quadratic complexity. The reviewer suggests optimizing this by scanning XML files textually in beforeCheckFile and limiting element scanning to only string and plurals tags.

@demolaf
demolaf force-pushed the auth/remove-unreferenced-strings branch from 1457f75 to 7ed73c8 Compare September 21, 2026 16:07
@demolaf
demolaf force-pushed the lint/unreferenced-resource-detector branch 2 times, most recently from 5da60c0 to 109874d Compare September 21, 2026 17:28
@demolaf
demolaf marked this pull request as ready for review September 28, 2026 14:18
@demolaf
demolaf force-pushed the auth/remove-unreferenced-strings branch from 7ed73c8 to 248cae6 Compare September 29, 2026 12:02
@demolaf
demolaf force-pushed the lint/unreferenced-resource-detector branch from 109874d to 2244d3d Compare September 29, 2026 12:03
@demolaf
demolaf force-pushed the auth/remove-unreferenced-strings branch from 248cae6 to 895be2b Compare September 29, 2026 12:04
@demolaf
demolaf force-pushed the lint/unreferenced-resource-detector branch from 2244d3d to f036fe0 Compare September 29, 2026 12:04
Base automatically changed from auth/remove-unreferenced-strings to pre-GA September 29, 2026 12:24
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

Successfully merging this pull request may close these issues.

1 participant