Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#2,578 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
sql, typescript
Área
databases

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C
Estrellas
73.2k
Forks
4.7k
Merge medio
2 h 16 min
PR fusionados (30 d)
423

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de colbymchenry/codegraph

Todos los issues de colbymchenry/codegraph

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.