Overview › Code Complexity & Hot Files
Code Complexity & Hot Files
Detailed static-analysis report for code complexity & hot files.
Executive summary
The codebase has a small number of very large files that concentrate complexity and risk. The biggest offenders: MainActivity.java at 5,411 lines with 100+ methods (a god-object), ContentstackDeliveryRepositoryImpl.kt at 3,164 lines, two large data-mappers above 2,400 lines, and MainWebViewFragment.kt at 2,567 lines. These few files alone account for an outsized share of bugs and review friction.
Top 10 longest Kotlin files (production)
| # | File | Lines | Role |
|---|---|---|---|
| 1 | shared/sdui/.../ContentstackDeliveryRepositoryImpl.kt | 3,164 | Contentstack remote delivery + caching |
| 2 | shared/sdui/.../mapper/ApiDataToRepoModelMapper.kt | 2,806 | API → domain transformation mapper |
| 3 | Costco/.../MainWebViewFragment.kt | 2,567 | Main webview fragment orchestration |
| 4 | shared/bff/.../MockGeofences.kt | 2,482 | Mock dataset (test/dev) |
| 5 | shared/sdui/.../mapper/RepoDataToUiComponentModelMapper.kt | 2,428 | Domain → UI component mapper |
| 6 | feature/warehouse/.../WarehouseLandingComponent.kt | 2,397 | Warehouse landing Composable |
| 7 | feature/productlisting/.../ProductListingViewModel.kt | 2,047 | PLP state machine |
| 8 | shared/sdui/.../usecase/SdUiUseCaseImpl.kt | 1,890 | Server-driven UI use case |
Top 10 longest Java files (production)
| # | File | Lines | Note |
|---|---|---|---|
| 1 | Costco/.../MainActivity.java | 5,411 | 100+ methods — extreme god-object |
| 2 | Costco/.../mobeta/dslv/DragSortListView.java | 2,964 | Vendored 3rd-party drag-sort list |
| 3 | Costco/.../FindAStoreFragment.java | 1,647 | Map + warehouse locator |
| 4 | Costco/.../SearchActivity.java | 1,128 | Legacy search |
| 5 | Costco/.../GeneralPreferencesImpl.java | 1,127 | Preferences god-object |
| 6 | Costco/.../OfferManagerImpl.java | 1,047 | Offer orchestration |
| 7 | Costco/.../WarehouseOffersFragment.java | 1,012 | Warehouse offers UI |
| 8 | Costco/.../SwipeAndDragListView.java | 974 | Custom list view |
| 9 | Costco/.../WarehouseDetailsHeaderView.java | 858 | |
| 10 | Costco/.../raizlabs/.../UniversalAdapter.java | 856 | Vendored adapter framework |
Findings
CRITICAL
MainActivity.java is a 5,411-line god-object
100+ public methods. Every change is a high-risk change; review velocity is poor; rotation/lifecycle bugs concentrate here. This file already accounts for many of the crash, lifecycle, and memory-leak findings in this report.
Recommendation: Plan a focused refactor sprint. Extract: deep-link routing →
DeepLinkRouter; tab/navigation → BottomTabCoordinator; webview management → MainWebViewController; intent handling → IntentHandler. Migrate to Kotlin in the same pass.HIGH
Mappers at 2,400-2,800 lines
ApiDataToRepoModelMapper + RepoDataToUiComponentModelMapper are giant transformations. They are correctness-critical (server-driven UI shape) but extremely hard to review or test thoroughly.Recommendation: Split per-component mappers (one mapper per UI component family). Use
sealed class hierarchies for typed inputs/outputs. Add property-based tests (kotest) for each mapper.HIGH
MainWebViewFragment.kt at 2,567 lines
Already implicated in 9+ crash/lifecycle/memory-leak findings. Hosts WebView state machine, deep-link handling, JS bridge, and tab navigation in one class.
Recommendation: Extract a
WebViewStateMachine, a JsBridgeRegistry, and a WebViewLifecycleObserver. Each becomes independently testable.MEDIUM
Two vendored open-source libraries inline (DSLV + Raizlabs UniversalAdapter)
Vendored copies do not get security patches. They also bloat the Costco app module.
Recommendation: Replace
DragSortListView with RecyclerView + ItemTouchHelper (or Compose's reorderable lists). Replace UniversalAdapter with native Compose lists.MEDIUM
Mock data file at 2,482 lines in production
shared/bff/.../MockGeofences.kt ships in the production source set.Recommendation: Move to
shared/bff/src/debug/ or a :testfixtures module so it doesn't bloat release builds.INFO
No complexity ratchet in CI
Without a budget, files trend longer over time. A simple ratchet (e.g. fail PRs that increase max file length) keeps creep in check.
Recommendation: Add Detekt rules
LargeClass, LongMethod, ComplexCondition, CyclomaticComplexMethod with reasonable thresholds (file ≤ 500, method ≤ 60, complexity ≤ 15).Costco Android · Code Review Report · Generated 2026-05-07 · 626 machine-curated findings