Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

getDominantFile returns null when test or generated files fill its 20-row window

オープン
#2,578 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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.ts has a chain of 60 functions, each calling the next (60 in-file edges), and src/second.ts has a chain of 50.
  • 20 files tests/tN.test.ts each 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
平均マージ
2時間 16分
マージ済み PR(30日)
423

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

colbymchenry/codegraph のほかの issue

colbymchenry/codegraph の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。