getDominantFile returns null when test or generated files fill its 20-row window
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #2785 来自 @colbymchenry —— 已合并
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 65/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- sql, typescript
- 领域
- databases
调研方向
Start in src/db/queries.ts at computeDominantFile and its LIMIT 20 query, then getTopRouteFile, which has the same truncate-then-filter shape. The consumer is the edgeCount >= 3 * nextEdgeCount check in src/context/index.ts. Reproduce with the 60-function src/core.ts chain and 20 tests/tN.test.ts files; done when getDominantFile() returns src/core.ts with edgeCount 60 and nextEdgeCount 50 instead of null.
由索引模型根据 Issue 内容生成。
描述
Summary
computeDominantFile takes the top 20 files by in-file edge count in SQL (LIMIT 20), and only then drops test and generated files in code. When 20 or more low-value files outrank the real code, nothing is left and it returns null, even though a clear dominant file exists. With fewer than 20 such files, nextEdgeCount can be understated, because the runner-up was cut off by the limit. That affects the edgeCount >= 3 * nextEdgeCount check that decides the directory boost.
Reproduction (verified)
On main at c71a3d03, built from source, Linux (WSL2), Node 22.22.2.
src/core.tshas a chain of 60 functions, each calling the next (60 in-file edges), andsrc/second.tshas a chain of 50.- 20 files
tests/tN.test.tseach have a chain of 70.
const cg = await CodeGraph.init(dir, { index: true });
(cg as any).queries.getDominantFile(); // → null
Expected: { filePath: 'src/core.ts', edgeCount: 60, nextEdgeCount: 50 }.
Generated code makes this plausible in real repos. Android R.java per module, protobuf *OuterClass.java / *Grpc.java, and test-heavy monorepos could fill the window.
Same pattern (inferred, not reproduced)
getTopRouteFile takes the 20 files with the most routes, then filters. Both totalRoutes and the 30% share check are computed on the truncated, filtered set.
Possible fix
Push the test-path exclusion into SQL, or keep fetching past 20 rows until 20 rows survive the filter (or the rows run out). The generated-file check needs the files table, so the second option may be simpler.
Related
#2575 (the plan fix for the same query, #2571), and #2349 / #2115, which cache the result. None of them changes the window.
- 主要语言
- C
- 星标
- 73.2k
- 派生
- 4.7k
- 平均合并
- 3 小时 15 分钟
- 30 天内合并 PR
- 576
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
colbymchenry/codegraph 的其他 Issue
-
mcp: a projectPath naming a file inside a project returns isError ("Path is not a directory")可能已有人在做 @maxmilian 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
colbymchenry/codegraph#2982 ·
维护者通常 1 天内回复
-
mcp: a non-object tools/call arguments crashes the handler and is reported as an internal error to retry可能已有人在做 @kjgggggg 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
colbymchenry/codegraph#2981 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
colbymchenry/codegraph#2974 ·
维护者通常 1 天内回复
-
search: FTS special characters are deleted, not separated, so leaf(entry) matches nothing可能已有人在做 @kjgggggg 于 2 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
colbymchenry/codegraph#2971 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
colbymchenry/codegraph#2959 · 1 条评论 ·
维护者通常 1 天内回复
查看 colbymchenry/codegraph 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
cyrusimap/cyrus-imapd#6640 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 60/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
GalusPeres/HomeTiles#139 · 1 条评论 ·
维护者通常 3 天内回复
-
Type: Bug
难度 2/5 1-3 小时 新手友好度 76/100
apache/nuttx-apps#3942 ·
维护者通常 1 天内回复
-
coders/mat.c: ReadMATImageV4 leaves a trailing 0x0 frame, so converting a valid level-4 .mat fails未关闭
难度 2/5 1-3 小时 新手友好度 72/100
ImageMagick/ImageMagick#9077 ·
维护者通常 1 天内回复