fix: address remaining quality issues across domains#774
fix: address remaining quality issues across domains#774carlos-alm merged 2 commits intofix/empty-catch-blocksfrom
Conversation
Extract sub-functions to reduce halsteadEffort and cognitive complexity in 11 FAIL targets: dependencies, communities, server, parser, context, overview, impact, exports, path, viewer, dataflow. All functions now pass gate thresholds (cognitive <= 30, halstead.bugs <= 1.0, MI >= 20).
|
Claude finished @carlos-alm's task —— View job PR Review: Quality Issues FixReviewing PR #774 for quality improvements across multiple domains. Todo List:
Root Cause AnalysisProblem Being Solved: Addresses FAIL-level quality issues (halsteadEffort violations) identified by quality analysis across multiple modules. Part of structured quality improvement effort following PRs #764 (empty catch fixes) and #765 (console.log fixes). Why This Approach: Uses proper refactoring by extracting helper functions rather than suppressing linting rules. Breaks down complex 80+ line functions into focused 20-30 line helpers with clear single responsibilities. Risk Assessment: Very low risk. Pure refactoring with no behavior changes, following established codebase patterns. Backlog Compliance
Critical ConcernsNone found. This is exemplary refactoring work: ✅ Quality of refactoring: All extractions follow Single Responsibility Principle Specific improvements:
Final Recommendation
|
Greptile SummaryThis PR is a pure complexity-reduction refactor across 11 files — no behavioral changes. Each changed file applies the same mechanical pattern: inline logic blocks that exceeded Halstead-effort thresholds are extracted into small, named helper functions. The extracted helpers ( Key observations:
Confidence Score: 5/5Safe to merge — all changes are pure extract-function refactors with no behavioral differences. Every extracted function is a mechanically faithful lift of its inline predecessor. The prior P1 type error on hc has been fixed. No new logic, no new exports, no API surface changes. All 11 files score 5/5 individually. No P0 or P1 findings remain. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as MCP Client
participant Server as startMCPServer
participant Factory as createCallToolHandler
participant Handler as CallToolHandler (closure)
participant Tools as TOOL_HANDLERS
Server->>Factory: createCallToolHandler(multiRepo, dbPath, allowedRepos, getQueries)
Factory-->>Server: async (request) => { ... }
Server->>Server: server.setRequestHandler(CallToolRequestSchema, handler)
Client->>Server: tool call request
Server->>Handler: invoke(request)
Handler->>Handler: validateMultiRepoAccess(multiRepo, name, args)
Handler->>Handler: resolveDbPath(customDbPath, args, allowedRepos)
Handler->>Tools: TOOL_HANDLERS.get(name)
Tools-->>Handler: toolEntry
Handler->>Handler: toolEntry.handler(args, ctx)
Handler-->>Client: { content: [...] }
Reviews (2): Last reviewed commit: "fix: correct hc parameter type in buildN..." | Re-trigger Greptile |
src/domain/analysis/dependencies.ts
Outdated
| function buildNodeDepsResult( | ||
| db: BetterSqlite3Database, | ||
| node: NodeRow, | ||
| hc: Map<unknown, unknown>, |
There was a problem hiding this comment.
Incorrect type for
hc — TypeScript error when passed to normalizeSymbol
normalizeSymbol declares its third parameter as hashCache?: Map<string, string | null> (see src/shared/normalize.ts:64). The newly extracted function types hc as Map<unknown, unknown>, which is not assignable to Map<string, string | null> because unknown does not satisfy the string | null value constraint on the return type of Map.get. TypeScript will emit a type error on the ...normalizeSymbol(node, db, hc) spread.
The original code passed an untyped new Map() (inferred as Map<any, any>) that was silently widened. The correct fix is to use the concrete type that normalizeSymbol actually expects:
| hc: Map<unknown, unknown>, | |
| hc: Map<string, string | null>, |
There was a problem hiding this comment.
Fixed — changed hc: Map<unknown, unknown> to hc: Map<string, string | null> to match normalizeSymbol's hashCache parameter type. Commit 50af5d7.
Change Map<unknown, unknown> to Map<string, string | null> to match normalizeSymbol's hashCache parameter type, fixing a TS2345 build error.
|
Addressed Greptile's review: Fixed the |
Summary
Titan Audit Context
Changes
src/domain/analysis/context.ts- Reduce complexitysrc/domain/analysis/dependencies.ts- Reduce complexitysrc/domain/parser.ts- Reduce complexitysrc/features/communities.ts- Reduce complexitysrc/mcp/server.ts- Reduce complexitysrc/presentation/dataflow.ts- Reduce complexitysrc/presentation/queries-cli/exports.ts- Reduce complexitysrc/presentation/queries-cli/impact.ts- Reduce complexitysrc/presentation/queries-cli/overview.ts- Reduce complexitysrc/presentation/queries-cli/path.ts- Reduce complexitysrc/presentation/viewer.ts- Reduce complexityTest plan