build: Improve NoAndroidLog checker and add integration tests
The NoAndroidLog checker was missing several edge cases when
android.util.Log is imported. Specifically:
- Static field access (e.g., Log.VERBOSE).
- Static imports (e.g., import static android.util.Log.ASSERT;).
- Class references (e.g., Log.class).
This CL updates the checker to use both IdentifierTreeMatcher and
MemberSelectTreeMatcher to catch these cases. It also adds logic to
de-duplicate warnings on nested matches (e.g., only one warning for
android.util.Log.d()).
An integration test suite (NoAndroidLogNoCompileSources.java) is added
to the nocompile test infrastructure to verify the checker's
effectiveness and ensure @SuppressWarnings("NoAndroidLog") continues to
work at the method and class level.
Bug: 481747262
Test: autoninja -C out/Debug tools/android/errorprone_plugin/test:errorprone_plugin_tests
Change-Id: I43e12093f5421a3847d7b65ba8fd346ad6aa3c25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7609321
Reviewed-by: Ziwen Lin <[email protected]>
Commit-Queue: Peter Wen <[email protected]>
Auto-Submit: Peter Wen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1592530}
NOKEYCHECK=True
GitOrigin-RevId: 7e101c25e15acbd0575f031c05b461a26d3552e3
5 files changed