JS/TS: functions assigned to object properties are not extracted; their calls land on the Module node
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- express, javascript, typescript
- 領域
- tooling
調査の方向性
Start with the function-naming path that Nix uses through cbm_nix_qn_name, and the call-scope code that attributes calls to the Module node, since both must share one helper for property-assigned JS/TS functions. Then read extract_handler_arg to see how route handlers are picked from the last-match argument. Done means a.b = function and a.b = () => … get Function nodes with the object path in their QN, route HANDLES edges land on the real handler, and the test suite and lint pass. The maintainer's answer on one PR versus two is still open.
索引モデルが issue の本文から書いたものです。
説明
Drafted with Claude Code (Anthropic); I reviewed it and am accountable for it.
- Version: v0.12.1 release, and current
mainat1ec2f262 - Platform: Linux x86_64 (Pop!_OS 24.04, gcc 13, glibc 2.39), built from source
- Confirmations: I searched existing issues and this is not a duplicate (related: #763, #1220, #1611, #2293, #2883/#2888). The snippets below are dummy code, not proprietary code.
What happens
CommonJS and Express code often defines functions as object properties:
authUtil.authenticate = function (req, res, next) { /* ... */ };
authController.getUser = async function (req, res) { /* ... */ };
service.processPayment = async (payment) => { /* ... */ };
On v0.12.1 and current main, none of these become Function nodes. Every call inside
their bodies is attributed to the file's Module node (a concrete case of #763), so
trace_path cannot start from them, callers of authUtil.authenticate resolve to
nothing, and route HANDLES edges cannot reach them.
Measured impact
On a production Express API (plain JavaScript, CommonJS, 532 files), current main
vs a fix:
| Metric | main |
patched |
|---|---|---|
| Function nodes | 579 | 1,563 |
| CALLS from Function nodes | 452 | 2,067 |
| CALLS from Module nodes | 1,332 | 1,120 |
Knock-on problem: route handler selection
Once these functions resolve, HANDLES lands on middleware. When the real handler is
wrapped (errorHandler(ctrl.fn)) or written inline, the last-match scan in
extract_handler_arg falls back to the last named middleware:
router.post("/x", routeUtil.authenticate, routeUtil.checkBankStatus,
errorHandler(ctrl.addBeneficiary));
// HANDLES -> checkBankStatus (expected: ctrl.addBeneficiary)
On the same codebase, fixing extraction alone produced about 420 HANDLES edges on auth
and validation middleware.
This touches the same function as #2888 (#2883). Per your review there, the JS/TS rule
here never takes the wrapper's callee: it takes the reference inside the wrapper
(errorHandler(ctrl.fn) → ctrl.fn), and an inline handler, including
asyncHandler(async (req, res) => …), gets no HANDLES edge. Because the patch gives
JS/TS its own path, it should sit alongside a Go/Rust-gated #2888 without interfering.
Proposal
- Name a
function_expressionorarrow_functionthat is the right-hand side of an
assignment to a static member path (a.b.c = function…) after the property, with
the object path in its QN. Share one helper between the definition side and the
call-scope side, as Nix does withcbm_nix_qn_name, so the two QNs cannot drift.
Leave named function expressions,module.exports = <anonymous fn>,this.x,
obj[k],f().xand optional chains unchanged. Only a function written directly on
the right-hand side is named, never the result of a call (the concern in #1220).
Following #2293, only name it where no named function encloses it (see below). - For JS/TS route registrations, take the handler from the final argument only
(skipping comments and a trailing options object), unwrapwrapper(ref)up to two
levels, and emit no handler for an inline function rather than the preceding middleware.
Fits the closure decision in #2293
I read your decision in #2293 to keep calls inside closures attributed to the enclosing
named function, and the proposal follows it. A property-assigned function is named only
where no named function encloses it: at file level, or inside an anonymous wrapper such
as module.exports = function (app) { … }, a test callback or an IIFE. In all of those
places its calls currently fall through to the Module, so naming it moves no edge away
from a named function. Inside a named function it is left alone:
function createPaymentService(db) {
const svc = {};
svc.pay = async (payment) => { db.insert(payment); };
return svc;
}
// unchanged: createPaymentService CALLS db.insert
In the Express API above, this keeps 989 of 992 property-assigned functions: 931 at
file level and 58 inside anonymous wrappers. The 3 inside a named function (a model
factory and a test helper) stay as they are.
I have a patch with regression tests for both fixes. It passes scripts/test.sh and
scripts/lint.sh --ci on current main. I can open a PR, or two if you'd prefer them
split. Would you prefer one PR or two?
- 主要言語
- C
- スター
- 45.8k
- フォーク
- 3.8k
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 108
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DeusData/codebase-memory-mcp のほかの issue
-
bug ux/behavior
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
DeusData/codebase-memory-mcp#3191 ·
メンテナーはふだん 1 日以内に返信
-
documentation enhancement parsing/quality ux/behavior
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
DeusData/codebase-memory-mcp#3131 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
hook-augment: the five-row cap keeps the first five search_graph rows, so variables and modules displace function definitions (v0.12.1)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug editor/integration parsing/quality ux/behavior
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
DeusData/codebase-memory-mcp#3062 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug documentation editor/integration parsing/quality
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
DeusData/codebase-memory-mcp#3050 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
editor/integration parsing/quality
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
DeusData/codebase-memory-mcp#2286 ·
メンテナーはふだん 1 日以内に返信
DeusData/codebase-memory-mcp の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
メンテナーはふだん 1 日以内に返信
-
iOS: the "Edit controls" button never hides, even with a controller connected, and covers the gameオープンgame: 010065A014024000 ios
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
seedds/nxnative#3714 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信