feat: name JS/TS arrow functions used as object methods + expand coverage#404
Merged
askpt merged 3 commits intoJun 22, 2026
Conversation
…overage
- jsLikeAnalyzer: arrow function assigned as an object property
(e.g. const api = { getData: () => {} }) now shows 'getData' in
CodeLens instead of the generic '(arrow function)' label. Handles
the 'pair' parent node type alongside the existing 'variable_declarator'
case.
- 5 new unit tests (126 → 131 passing):
- object-method arrow function naming (new feature)
- while loop in JavaScript (covers getComplexityReason 'while loop')
- nested class method inside a function (covers getFunctionReason
'method (nested)')
- module.exports arrow function → '(arrow function)' fallback
- anonymous IIFE function expression → '(anonymous)' fallback
- jsLikeAnalyzer coverage: 97.87% → 99.53% stmts, 90.81% → 94.23% branches
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…coverage-20260622-588e53addfdcdf86
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #404 +/- ##
==========================================
+ Coverage 76.96% 77.21% +0.24%
==========================================
Files 13 13
Lines 4107 4116 +9
Branches 440 444 +4
==========================================
+ Hits 3161 3178 +17
+ Misses 943 934 -9
- Partials 3 4 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…coverage-20260622-588e53addfdcdf86
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the JavaScript/TypeScript function naming shown in CodeLens by naming arrow functions used as object-literal property values (e.g., { getData: () => {} }) with the property key, and it expands unit test coverage for JsLikeMetricsAnalyzer to cover additional previously-untested branches.
Changes:
- Update
JsLikeMetricsAnalyzer.getFunctionName()to derive arrow-function names from the enclosing object-literalpairkey. - Add 5 new unit tests covering: object-method arrow naming,
whileloop reason/complexity, nested class method handling, and anonymous/arrow fallback names.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/metricsAnalyzer/languages/jsLikeAnalyzer.ts |
Enhances arrow-function naming by extracting the object property key when the arrow function is the value in an object literal pair. |
src/unit/unit.test.ts |
Adds targeted unit tests to validate the new naming behavior and increase coverage for several existing branches/reason strings. |
askpt
approved these changes
Jun 22, 2026
This was referenced Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist.
Summary
Two improvements in one PR (Task 5 – Coding Improvement + test coverage):
Arrow function object-method naming (UX improvement): JS/TS CodeLens now shows the property key name when an arrow function is the value of an object literal property, instead of the generic
(arrow function)label.Expanded test coverage: 5 new unit tests covering previously-untested code paths in
jsLikeAnalyzer. Test count: 126 → 131 passing.Task 5: Arrow Function Object-Method Naming
Before / After
const api = { getData: () => { if(f){} } }(arrow function)getDataconst fn = () => { if(f){} }fn(unchanged)fnmodule.exports = () => { if(f){} }(arrow function)(unchanged)(arrow function)Implementation (
jsLikeAnalyzer.ts)Added a
pairparent check inside thearrow_functionbranch ofgetFunctionName:Rationale
When a file exports a plain object of functions (common in module patterns, route handlers, service objects), every arrow function showed as
(arrow function)in CodeLens. With this fix, each entry shows the property name, making it immediately clear which function a high-complexity CodeLens belongs to.Test Coverage Added
getComplexityReason"while loop" branch (line 384)getFunctionReason"method (nested)" branch (line 168)module.exports = () => {}→(arrow function)(function(){})()→(anonymous)jsLikeAnalyzer coverage: 97.87% → 99.53% stmts, 90.81% → 94.23% branches
Test Status
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
releaseassets.githubusercontent.comSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run