Conversation
…ctionDetails - Replace four near-identical create*Analyzer functions in metricsAnalyzerFactory.ts with a single generic createAnalyzer(modulePath, className) helper. All four functions shared the same shape: lazy require(), analyzeFile() call, and 0→1 line/column normalization on detail positions. The helper removes ~140 lines of duplication while preserving identical runtime behaviour (Node.js module cache ensures the require() overhead is paid only once per language). - Implement cognitiveComplexity.showFunctionDetails command in extension.ts. Previously a no-op, the command now writes a formatted complexity breakdown to a dedicated 'Code Metrics Details' output channel and reveals it with preserveFocus so the editor cursor stays in place. The channel is created lazily and disposed on deactivation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors the metrics analyzer factory to reduce per-language duplication and implements the previously no-op cognitiveComplexity.showFunctionDetails command to show a complexity breakdown in a dedicated VS Code output channel.
Changes:
- Replaced per-language analyzer wrapper functions with a generic
createAnalyzer(modulePath, className)helper. - Implemented
showFunctionDetailscommand to render function complexity details to a shared “Code Metrics Details” output channel. - Disposed the shared output channel on extension deactivation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/metricsAnalyzer/metricsAnalyzerFactory.ts | Consolidates language analyzer creation/normalization into a single helper and updates the language analyzer registry. |
| src/extension.ts | Adds a real showFunctionDetails command implementation, using a shared output channel and disposing it on deactivate. |
|
@copilot apply changes based on the comments in this thread |
…ix empty-details message Agent-Logs-Url: https://github.com/askpt/code-metrics/sessions/3faebe2a-5bfd-4cf2-b9b2-93fdaa3e8e58 Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Applied both review comments in commit
|
|
@copilot the build is failing. please fix it |
… test failure Agent-Logs-Url: https://github.com/askpt/code-metrics/sessions/bf3ddd58-ca9b-43db-8946-9201af04d92c Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Fixed in commit |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #230 +/- ##
==========================================
- Coverage 68.50% 67.45% -1.05%
==========================================
Files 8 8
Lines 3000 2928 -72
Branches 279 276 -3
==========================================
- Hits 2055 1975 -80
- Misses 943 951 +8
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot Based on #230 (comment) increase the code coverage |
…ory.ts Agent-Logs-Url: https://github.com/askpt/code-metrics/sessions/1444435e-d531-4fbe-bb32-aec60a7765e5 Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Added coverage improvements in commit
|
Refactors the metrics analyzer factory to reduce per-language duplication and implements the previously no-op
cognitiveComplexity.showFunctionDetailscommand to show a complexity breakdown in a dedicated VS Code output channel.Changes Made
metricsAnalyzerFactory.ts: Replaced per-language analyzer wrapper functions with a genericcreateAnalyzer(modulePath, className)helper. AddedRawMetricsDetail,RawFunctionMetrics, andAnalyzerClassinterfaces to replaceanytypes. Added a runtime guard that throws a descriptive error when the expected class oranalyzeFilemethod is not found. ExportedcreateAnalyzerto enable direct unit testing of the guard.extension.ts: ImplementedshowFunctionDetailscommand to render function complexity details to a shared "Code Metrics Details" output channel. Fixed misleading empty-details message to "No complexity contributors were reported." Added an early-return guard whenfuncisundefined. Disposes the shared output channel on extension deactivation.Test Coverage
Added tests to cover previously-uncovered code paths:
extension.test.ts: Tests for the table-rendering branch (details.length > 0), output channel reuse when the command is called multiple times, and thedeactivate()disposal path.metricsAnalyzerFactory.test.ts: Test for thecreateAnalyzerruntime error guard, verifying a descriptive error is thrown when a module does not export the expected class.Testing