The following functions and files have been identified by our automated complexity analysis as candidates for refactoring. They currently exceed the established thresholds for cyclomatic complexity and/or function length (as configured in .eslintrc.js).
-
mapToOnChainErrorinsrc/types/OnChainErrorCodes.ts- Metrics: Cyclomatic complexity of 24 (limit: 15), 125 lines (limit: 50).
- Reason: Large switch/if-else chains mapping contract errors. Consider extracting to a mapping object or smaller helpers.
-
startSongWorkerinsrc/workers/SongProcessorWorker.ts- Metrics: Cyclomatic complexity of 18 (limit: 15), 196 lines (limit: 50).
- Reason: Heavy business logic and deeply nested async arrow functions. Extract the inner job processing logic into its own method or class.
-
finalizeUploadinsrc/services/SongService.ts- Metrics: 126 lines (limit: 50), 9 parameters (limit: 5).
- Reason: Handles too many responsibilities (chunk merging, DB updates, queueing). Extract S3/file logic or introduce an options object for parameters.
-
Twitter OAuth Callback (
router.get('/callback')) insrc/routes/twitterRoutes.ts- Metrics: Cyclomatic complexity of 16 (limit: 15), 100 lines (limit: 50).
- Reason: Mixes API requests, database queries, and session management. Extract Twitter API calls and user linking logic to a dedicated service.
Note: This list is intended to guide future tech debt sprints. New code should adhere to the complexity limits enforced by CI.