Skip to content

fix(lint): disable hanging androidx.fragment lifecycle detector#36

Merged
luisguzman-adfa merged 2 commits into
mainfrom
fix/lint-fragment-detector-hang
Jun 24, 2026
Merged

fix(lint): disable hanging androidx.fragment lifecycle detector#36
luisguzman-adfa merged 2 commits into
mainfrom
fix/lint-fragment-detector-hang

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Problem

:app:lintDebug doesn't run slow — it hangs, burning CPU indefinitely inside one detector that ships with androidx.fragment: UnsafeFragmentLifecycleObserverDetector. Its RecursiveMethodVisitor walks the call graph recursively per Fragment method; on our oversized Fragment/Activity methods (DeployFragment ~2.7k LOC, MainActivity, full of nested lambdas) this degrades to near-exponential cost and never finishes. CI's lint step ran ~50 min normally, up to ~3 h on heavy branches.

Fix

Disable the detector's 3 issue IDs — the only ones it emits — in lintOptions:

disable 'FragmentBackPressedCallback', 'FragmentLiveDataObserve', 'FragmentAddMenuProvider'

Lint then completes in minutes. The other 450+ checks stay active, and abortOnError true + the committed lint-baseline.xml gate is unchanged.

Why it's safe / scoped

  • The baseline (468 issues) has no Fragment* entries — the detector never completed, so nothing in the baseline depends on it.
  • Only this one pathological detector is turned off; no security/correctness checks are affected.

Out of scope (follow-ups)

  • Regenerate lint-baseline.xml (drop ~10 stale entries; fix the fresh warnings instead of forgiving them).
  • P1 security fixes (TrustAllX509TrustManager, UnspecifiedRegisterReceiverFlag, MissingSuperCall, …).
  • P3 typography sweep to shrink the baseline.
  • Real cause: split DeployFragment/MainActivity (see controller/docs/TECH_DEBT_PLAN.md); once methods shrink, drop this disable and re-enable the 3 checks.

Verification

CI's Run Android Lint step on this PR should drop from ~50 min to a few minutes and stay green (no new lint errors). Local lint couldn't be run in the prep environment (no Android SDK).

:app:lintDebug hangs for hours inside androidx.fragment's
UnsafeFragmentLifecycleObserverDetector — its recursive call-graph walk
degrades to near-exponential cost on our oversized Fragment/Activity methods
(DeployFragment ~2.7k LOC, MainActivity). CI's lint step ran ~50 min, up to 3 h
on heavy branches.

Disable the detector's 3 issue IDs (FragmentBackPressedCallback,
FragmentLiveDataObserve, FragmentAddMenuProvider) — the only ones it emits — so
lint completes in minutes. The other 450+ checks (and abortOnError + baseline)
stay active. Re-enable once the god classes are split (TECH_DEBT_PLAN.md).
…debt

Logs the lintOptions workaround in TECH_DEBT_PLAN.md (Progress log + Phase 3
cross-ref) with the explicit re-enable condition: drop the disable once
DeployFragment/MainActivity are carved up. Keeps the comment in build.gradle
honest — the debt is now tracked, not just referenced.
@luisguzman-adfa luisguzman-adfa merged commit 51fa5b9 into main Jun 24, 2026
1 check passed
@luisguzman-adfa luisguzman-adfa deleted the fix/lint-fragment-detector-hang branch June 24, 2026 01:39
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