Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#2,578 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
sql, typescript
Ambito
databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C
Stelle
73.2k
Fork
4.7k
Merge medio
4h 46m
PR unite (30g)
478

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di colbymchenry/codegraph

Tutte le issue di colbymchenry/codegraph

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.