Overview › Code Complexity & Hot Files

Code Complexity & Hot Files

Detailed static-analysis report for code complexity & hot files.

Source: codebase scan · 2026-05-07

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)

#FileLinesRole
1shared/sdui/.../ContentstackDeliveryRepositoryImpl.kt3,164Contentstack remote delivery + caching
2shared/sdui/.../mapper/ApiDataToRepoModelMapper.kt2,806API → domain transformation mapper
3Costco/.../MainWebViewFragment.kt2,567Main webview fragment orchestration
4shared/bff/.../MockGeofences.kt2,482Mock dataset (test/dev)
5shared/sdui/.../mapper/RepoDataToUiComponentModelMapper.kt2,428Domain → UI component mapper
6feature/warehouse/.../WarehouseLandingComponent.kt2,397Warehouse landing Composable
7feature/productlisting/.../ProductListingViewModel.kt2,047PLP state machine
8shared/sdui/.../usecase/SdUiUseCaseImpl.kt1,890Server-driven UI use case

Top 10 longest Java files (production)

#FileLinesNote
1Costco/.../MainActivity.java5,411100+ methods — extreme god-object
2Costco/.../mobeta/dslv/DragSortListView.java2,964Vendored 3rd-party drag-sort list
3Costco/.../FindAStoreFragment.java1,647Map + warehouse locator
4Costco/.../SearchActivity.java1,128Legacy search
5Costco/.../GeneralPreferencesImpl.java1,127Preferences god-object
6Costco/.../OfferManagerImpl.java1,047Offer orchestration
7Costco/.../WarehouseOffersFragment.java1,012Warehouse offers UI
8Costco/.../SwipeAndDragListView.java974Custom list view
9Costco/.../WarehouseDetailsHeaderView.java858
10Costco/.../raizlabs/.../UniversalAdapter.java856Vendored 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