Count the intended corpus, then prove each use() kept its exact local LSP * call. Query errors are failures, never indistinguishable from zero rows. */
| 478 | /* Count the intended corpus, then prove each use() kept its exact local LSP |
| 479 | * call. Query errors are failures, never indistinguishable from zero rows. */ |
| 480 | static bool cx_pyext_control(cbm_store_t *store, const char *project, const cbm_node_t *caller) { |
| 481 | if (!caller->qualified_name || !caller->file_path) |
| 482 | return false; |
| 483 | const char *dot = strrchr(caller->qualified_name, '.'); |
| 484 | if (!dot || dot - caller->qualified_name > 1000) |
| 485 | return false; |
| 486 | char target_qn[1200]; |
| 487 | int n = snprintf(target_qn, sizeof(target_qn), "%.*s.cx_pyext_definition_0", |
| 488 | (int)(dot - caller->qualified_name), caller->qualified_name); |
| 489 | if (n < 0 || (size_t)n >= sizeof(target_qn)) |
| 490 | return false; |
| 491 | cbm_node_t target = {0}; |
| 492 | cbm_edge_t *edges = NULL; |
| 493 | int count = 0; |
| 494 | bool found = false; |
| 495 | if (cbm_store_find_node_by_qn(store, project, target_qn, &target) == CBM_STORE_OK && |
| 496 | target.label && strcmp(target.label, "Function") == 0 && target.file_path && |
| 497 | strcmp(target.file_path, caller->file_path) == 0 && |
| 498 | cbm_store_find_edges_by_source_type(store, caller->id, "CALLS", &edges, &count) == |
| 499 | CBM_STORE_OK) { |
| 500 | for (int i = 0; i < count; i++) { |
| 501 | if (edges[i].target_id != target.id || !edges[i].properties_json) |
| 502 | continue; |
| 503 | /* an LSP resolution records an lsp_* strategy (lsp_direct here) */ |
| 504 | yyjson_doc *doc = |
| 505 | yyjson_read(edges[i].properties_json, strlen(edges[i].properties_json), 0); |
| 506 | const char *strategy = |
| 507 | doc ? yyjson_get_str(yyjson_obj_get(yyjson_doc_get_root(doc), "strategy")) : NULL; |
| 508 | found = found || (strategy && strncmp(strategy, "lsp_", 4) == 0); |
| 509 | yyjson_doc_free(doc); |
| 510 | } |
| 511 | } |
| 512 | cbm_store_free_edges(edges, count); |
| 513 | cbm_node_free_fields(&target); |
| 514 | return found; |
| 515 | } |
| 516 | |
| 517 | static bool cx_pyext_population(cbm_store_t *store, const char *project, CxMetrics *out) { |
| 518 | cbm_node_t *nodes = NULL; |
no test coverage detected