Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

chore(lint): one helper for pass_calls' transient-QN lookups

Martin Vogel1d5ff68e508e
diff --git a/scripts/memory-core-baseline.txt b/scripts/memory-core-baseline.txt
index ee54b498b..f3ab06913 100644
--- a/scripts/memory-core-baseline.txt
+++ b/scripts/memory-core-baseline.txt
@@ -57,7 +57,7 @@ src/pipeline/artifact.c 38
src/pipeline/fqn.c 23
src/pipeline/lsp_resolve.h 4
src/pipeline/lsp_surface.c 5
-src/pipeline/pass_calls.c 23
+src/pipeline/pass_calls.c 22
src/pipeline/pass_compile_commands.c 17
src/pipeline/pass_complexity.c 15
src/pipeline/pass_configlink.c 3
diff --git a/src/pipeline/pass_calls.c b/src/pipeline/pass_calls.c
index dff3a878a..5ada35f9d 100644
--- a/src/pipeline/pass_calls.c
+++ b/src/pipeline/pass_calls.c
@@ -107,6 +107,16 @@ static char *extract_local_name_from_json(const char *props_json) {
return cbm_strndup(start, end - start);
}
+/* The graph node whose QN is cbm_pipeline_fqn_compute(project, rel_path, name),
+ * or NULL. The one place this pass computes a transient QN for a lookup. */
+static const cbm_gbuf_node_t *pc_find_by_computed_qn(const cbm_gbuf_t *gbuf, const char *project,
+ const char *rel_path, const char *name) {
+ char *qn = cbm_pipeline_fqn_compute(project, rel_path, name);
+ const cbm_gbuf_node_t *n = qn ? cbm_gbuf_find_by_qn(gbuf, qn) : NULL;
+ free(qn);
+ return n;
+}
+
static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,
const CBMFileResult *result, const char ***out_keys,
const char ***out_vals, int *out_count) {
@@ -153,9 +163,8 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,
}
/* Slow path: scan graph buffer IMPORTS edges + parse JSON properties */
- char *file_qn = cbm_pipeline_fqn_compute(ctx->project_name, rel_path, "__file__");
- const cbm_gbuf_node_t *file_node = cbm_gbuf_find_by_qn(ctx->gbuf, file_qn);
- free(file_qn);
+ const cbm_gbuf_node_t *file_node =
+ pc_find_by_computed_qn(ctx->gbuf, ctx->project_name, rel_path, "__file__");
if (!file_node) {
return 0;
}
@@ -251,9 +260,7 @@ static const cbm_gbuf_node_t *pc_module_var(const cbm_gbuf_t *gbuf, const char *
if (!file_rel) {
return NULL;
}
- char *qn = cbm_pipeline_fqn_compute(project, file_rel, name);
- const cbm_gbuf_node_t *n = qn ? cbm_gbuf_find_by_qn(gbuf, qn) : NULL;
- free(qn);
+ const cbm_gbuf_node_t *n = pc_find_by_computed_qn(gbuf, project, file_rel, name);
return (n && n->label && strcmp(n->label, "Variable") == 0) ? n : NULL;
}
@@ -630,9 +637,7 @@ static const cbm_gbuf_node_t *calls_find_source(cbm_pipeline_ctx_t *ctx, const c
}
}
if (!src) {
- char *fqn = cbm_pipeline_fqn_compute(ctx->project_name, rel, "__file__");
- src = cbm_gbuf_find_by_qn(ctx->gbuf, fqn);
- free(fqn);
+ src = pc_find_by_computed_qn(ctx->gbuf, ctx->project_name, rel, "__file__");
}
return src;
}