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.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Eliminate NOLINTNEXTLINE suppressions + iterative AST walkers
Martin Vogelf26acd4ced1d
diff --git a/.clang-tidy b/.clang-tidyindex 1b6e97265..dbfe04ec8 100644--- a/.clang-tidy+++ b/.clang-tidy@@ -2,6 +2,32 @@## ALL checks enabled. WarningsAsErrors: '*'.# Check thresholds configured for idiomatic C11 (not C++).+#+# Globally disabled checks must have an upstream bug reference or+# architectural justification. Re-evaluate on LLVM upgrades.+#+# Documented LLVM false positives:+# bugprone-multi-level-implicit-pointer-conversion — LLVM #93959, relaxed in LLVM 19+# clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling — LLVM #64027+# clang-analyzer-optin.portability.UnixAPI — malloc(0) behavior, guarded in code+#+# Architectural:+# bugprone-command-processor — popen required for git, inputs validated+# cert-env33-c — popen/system needed for git commands, inputs validated+#+# Pending fix (phases 4-6):+# bugprone-easily-swappable-parameters — Phase 5: struct params+# concurrency-mt-unsafe — Phase 4: thread-safe wrappers+# cert-err33-c — Phase 4: check fwrite/fseek return values+# performance-no-int-to-ptr — Phase 4: union type-punning+# bugprone-branch-clone — Phase 6+# readability-avoid-nested-conditional-operator — Phase 6+# readability-redundant-casting — Phase 6+# bugprone-implicit-widening-of-multiplication-result — Phase 6+# bugprone-unchecked-string-to-number-conversion — Phase 6+# clang-analyzer-core.CallAndMessage — Phase 6+# clang-analyzer-core.NullPointerArithm — Phase 6+# clang-analyzer-security.insecureAPI.strcpy — Phase 6Checks: >-*,@@ -16,41 +42,39 @@ Checks: >readability-*,clang-analyzer-*,-misc-no-recursion,+ -readability-implicit-bool-conversion,-bugprone-multi-level-implicit-pointer-conversion,- -bugprone-branch-clone,+ -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,+ -clang-analyzer-optin.portability.UnixAPI,+ -clang-analyzer-security.ArrayBound,+ -clang-analyzer-unix.Malloc,+ -misc-include-cleaner,-bugprone-command-processor,+ -cert-env33-c,+ -bugprone-easily-swappable-parameters,+ -concurrency-mt-unsafe,+ -cert-err33-c,+ -performance-no-int-to-ptr,+ -bugprone-branch-clone,-readability-avoid-nested-conditional-operator,-readability-redundant-casting,-bugprone-implicit-widening-of-multiplication-result,-bugprone-unchecked-string-to-number-conversion,- -bugprone-easily-swappable-parameters,-clang-analyzer-core.CallAndMessage,- -clang-analyzer-security.ArrayBound,- -clang-analyzer-unix.Malloc,- -clang-analyzer-optin.portability.UnixAPI,-clang-analyzer-core.NullPointerArithm,- -performance-no-int-to-ptr,- -concurrency-mt-unsafe,- -cert-err33-c,- -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-security.insecureAPI.strcpy,- -misc-include-cleaner,WarningsAsErrors: '*'CheckOptions:bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources: false- # C idiom: i, j, k, n, p, s are standard variable namesreadability-identifier-length.MinimumVariableNameLength: 1readability-identifier-length.MinimumParameterNameLength: 1readability-identifier-length.MinimumLoopCounterNameLength: 1- # C idiom: if (!ptr), if (count) are standardreadability-implicit-bool-conversion.AllowIntegerConditions: truereadability-implicit-bool-conversion.AllowPointerConditions: true- # Systems C uses bit shifts, buffer sizes, hash constants, protocol sizesreadability-magic-numbers.IgnoredIntegerValues: "1;2;3;4;5;6;7;8;9;10;11;12;14;15;16;20;24;32;48;64;100;128;200;256;493;512;755;1000;1024;1040;2048;4096;8192;16384;32768;65536;500000;1000000;1000000000"readability-magic-numbers.IgnoredFloatingPointValues: "0.0;0.25;0.5;0.7;0.75;0.8;0.85;0.9;0.95;1.0;2.0;100.0;1e308"- # Cypher parser + tree-sitter resolver have deeply nested execution logicreadability-function-cognitive-complexity.Threshold: 250readability-function-size.StatementThreshold: 400readability-function-size.LineThreshold: 800diff --git a/internal/cbm/ac.c b/internal/cbm/ac.cindex f996a4af8..61754cfa8 100644--- a/internal/cbm/ac.c+++ b/internal/cbm/ac.c@@ -45,12 +45,10 @@ typedef struct {static void queue_init(Queue *q, int cap) {q->data = (int *)malloc(cap * sizeof(int));- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)q->head = q->tail = 0;q->cap = cap;}static void queue_push(Queue *q, int v) {- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)q->data[q->tail++] = v;}static int queue_pop(Queue *q) {@@ -128,7 +126,6 @@ CBMAutomaton *cbm_ac_build(const char **patterns, const int *lengths, int count,}// Mark this state as accepting pattern p.if (p < CBM_AC_MAX_BITMASK) {- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)ac->output[state] |= (1ULL << p);}// Append to output list.@@ -147,15 +144,12 @@ CBMAutomaton *cbm_ac_build(const char **patterns, const int *lengths, int count,int *fail = (int *)calloc(num_states, sizeof(int));Queue q;- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)queue_init(&q, num_states);// Depth-1 states: failure → root.for (int c = 0; c < alpha_size; c++) {- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)int s = ac->go_table[c]; // root's goto for cif (s != 0) {- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)fail[s] = 0;queue_push(&q, s);}@@ -166,11 +160,9 @@ CBMAutomaton *cbm_ac_build(const char **patterns, const int *lengths, int count,int r = queue_pop(&q);for (int c = 0; c < alpha_size; c++) {int idx = (r * alpha_size) + c;- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)int s = ac->go_table[idx];if (s != -1) {// s exists in trie- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)fail[s] = ac->go_table[(fail[r] * alpha_size) + c];// Merge output: dictionary suffix links.ac->output[s] |= ac->output[fail[s]];@@ -250,7 +242,6 @@ uint64_t cbm_ac_scan_bitmask(const CBMAutomaton *ac, const char *text, int text_// Thread-local reusable decompression buffer to avoid repeated malloc/free.// Each goroutine gets its own OS thread (via CGo), so CBM_TLS is safe.-// NOLINTNEXTLINE(clang-analyzer-optin.portability.UnixAPI)static CBM_TLS char *tls_decomp_buf = NULL;static CBM_TLS int tls_decomp_cap = 0;@@ -259,7 +250,6 @@ static char *get_decomp_buf(int needed) {free(tls_decomp_buf);// Round up to 64KB chunks for reuse.int cap = (needed + DECOMP_BUF_ALIGN_MASK) & ~DECOMP_BUF_ALIGN_MASK;- // NOLINTNEXTLINE(clang-analyzer-optin.portability.UnixAPI)tls_decomp_buf = (char *)malloc((size_t)cap);tls_decomp_cap = cap;}@@ -364,7 +354,6 @@ int cbm_ac_scan_lz4_batch(const CBMAutomaton *ac, const CBMLz4Entry *entries, in// num_names — number of names// out_matches — output buffer for (name_index, pattern_id) pairs// max_matches — capacity of out_matches-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_ac_scan_batch(const CBMAutomaton *ac, const char *names_buf, const int *name_offsets,const int *name_lengths, int num_names, CBMMatchResult *out_matches,int max_matches) {diff --git a/internal/cbm/cbm.c b/internal/cbm/cbm.cindex 70db0ce4d..086e8529d 100644--- a/internal/cbm/cbm.c+++ b/internal/cbm/cbm.c@@ -27,13 +27,11 @@ static _Atomic uint64_t total_files = 0;static uint64_t now_ns(void) {struct timespec ts;- // NOLINTNEXTLINE(misc-include-cleaner) — clock_gettime provided by standard headercbm_clock_gettime(CLOCK_MONOTONIC, &ts);return ((uint64_t)ts.tv_sec * NSEC_PER_SEC) + (uint64_t)ts.tv_nsec;}// cbm_get_profile returns accumulated parse/extract times and file count.-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)void cbm_get_profile(uint64_t *parse_ns, uint64_t *extract_ns, uint64_t *files) {*parse_ns = atomic_load(&total_parse_ns);*extract_ns = atomic_load(&total_extract_ns);diff --git a/internal/cbm/extract_calls.c b/internal/cbm/extract_calls.cindex c17e68360..64ca974d4 100644--- a/internal/cbm/extract_calls.c+++ b/internal/cbm/extract_calls.c@@ -42,7 +42,7 @@ static const char *strip_quotes(CBMArena *a, const char *text) {}// Forward declarations-static void walk_calls(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec);+static void walk_calls(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec);static char *extract_callee_name(CBMArena *a, TSNode node, const char *source, CBMLanguage lang);static void extract_jsx_refs(CBMExtractCtx *ctx, TSNode node);@@ -276,77 +276,75 @@ static char *extract_callee_name(CBMArena *a, TSNode node, const char *source, Creturn NULL;}-// Walk AST for call nodes-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk-static void walk_calls(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {- const char *kind = ts_node_type(node);-- if (cbm_kind_in_set(node, spec->call_node_types)) {- char *callee = extract_callee_name(ctx->arena, node, ctx->source, ctx->language);- if (callee && callee[0]) {- // Skip keywords- if (!cbm_is_keyword(callee, ctx->language)) {- CBMCall call = {0};- call.callee_name = callee;- call.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);- call.first_string_arg = NULL;-- /* Extract first string literal argument (URL, topic, key) */- TSNode args = ts_node_child_by_field_name(node, "arguments", 9);- if (!ts_node_is_null(args)) {- uint32_t nc = ts_node_named_child_count(args);- for (uint32_t ai = 0; ai < nc && ai < 3; ai++) {- TSNode arg = ts_node_named_child(args, ai);- const char *ak = ts_node_type(arg);- if (strcmp(ak, "string") == 0 || strcmp(ak, "string_literal") == 0 ||- strcmp(ak, "interpreted_string_literal") == 0 ||- strcmp(ak, "raw_string_literal") == 0 ||- strcmp(ak, "string_content") == 0) {- char *text = cbm_node_text(ctx->arena, arg, ctx->source);- if (text && text[0]) {- /* Strip quotes */- int len = (int)strlen(text);- if (len >= 2 && (text[0] == '"' || text[0] == '\'')) {- text =- cbm_arena_strndup(ctx->arena, text + 1, (size_t)(len - 2));- len -= 2;- }- /* Validate: must be printable ASCII, no control chars */- // NOLINTNEXTLINE(readability-implicit-bool-conversion)- bool valid = (text != NULL && len > 0 && len < 512);- for (int vi = 0; vi < len && valid; vi++) {- unsigned char ch = (unsigned char)text[vi];- if (ch < 0x20 && ch != '\t') {- valid = false;+// Walk AST for call nodes (iterative)+#define CALLS_STACK_CAP 512+static void walk_calls(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) {+ TSNode stack[CALLS_STACK_CAP];+ int top = 0;+ stack[top++] = root;++ while (top > 0) {+ TSNode node = stack[--top];+ const char *kind = ts_node_type(node);++ if (cbm_kind_in_set(node, spec->call_node_types)) {+ char *callee = extract_callee_name(ctx->arena, node, ctx->source, ctx->language);+ if (callee && callee[0]) {+ if (!cbm_is_keyword(callee, ctx->language)) {+ CBMCall call = {0};+ call.callee_name = callee;+ call.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);+ call.first_string_arg = NULL;++ TSNode args = ts_node_child_by_field_name(node, "arguments", 9);+ if (!ts_node_is_null(args)) {+ uint32_t nc = ts_node_named_child_count(args);+ for (uint32_t ai = 0; ai < nc && ai < 3; ai++) {+ TSNode arg = ts_node_named_child(args, ai);+ const char *ak = ts_node_type(arg);+ if (strcmp(ak, "string") == 0 || strcmp(ak, "string_literal") == 0 ||+ strcmp(ak, "interpreted_string_literal") == 0 ||+ strcmp(ak, "raw_string_literal") == 0 ||+ strcmp(ak, "string_content") == 0) {+ char *text = cbm_node_text(ctx->arena, arg, ctx->source);+ if (text && text[0]) {+ int len = (int)strlen(text);+ if (len >= 2 && (text[0] == '"' || text[0] == '\'')) {+ text = cbm_arena_strndup(ctx->arena, text + 1,+ (size_t)(len - 2));+ len -= 2;+ }+ bool valid = (text != NULL && len > 0 && len < 512);+ for (int vi = 0; vi < len && valid; vi++) {+ unsigned char ch = (unsigned char)text[vi];+ if (ch < 0x20 && ch != '\t') {+ valid = false;+ }+ }+ if (valid) {+ call.first_string_arg = text;}}- if (valid) {- call.first_string_arg = text;- }+ break;}- break;}}+ cbm_calls_push(&ctx->result->calls, ctx->arena, call);}-- cbm_calls_push(&ctx->result->calls, ctx->arena, call);}}- // Don't recurse into call arguments for nested calls — the walk handles that- }- // JSX component refs (TSX/JSX)- if (ctx->language == CBM_LANG_TSX || ctx->language == CBM_LANG_JAVASCRIPT) {- if (strcmp(kind, "jsx_self_closing_element") == 0 ||- strcmp(kind, "jsx_opening_element") == 0) {- extract_jsx_refs(ctx, node);+ if (ctx->language == CBM_LANG_TSX || ctx->language == CBM_LANG_JAVASCRIPT) {+ if (strcmp(kind, "jsx_self_closing_element") == 0 ||+ strcmp(kind, "jsx_opening_element") == 0) {+ extract_jsx_refs(ctx, node);+ }}- }- // Recurse- uint32_t count = ts_node_child_count(node);- for (uint32_t i = 0; i < count; i++) {- walk_calls(ctx, ts_node_child(node, i), spec);+ uint32_t count = ts_node_child_count(node);+ for (int i = (int)count - 1; i >= 0 && top < CALLS_STACK_CAP; i--) {+ stack[top++] = ts_node_child(node, (uint32_t)i);+ }}}@@ -542,7 +540,6 @@ void handle_calls(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, Walklen -= 2;}/* Validate printable */- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool valid = (text != NULL && len > 0 && len < 512);for (int vi = 0; vi < len && valid; vi++) {if ((unsigned char)text[vi] < 0x20 && text[vi] != '\t') {diff --git a/internal/cbm/extract_defs.c b/internal/cbm/extract_defs.cindex 073857b91..b6ce4f6c2 100644--- a/internal/cbm/extract_defs.c+++ b/internal/cbm/extract_defs.c@@ -22,7 +22,7 @@// Forward declarationsstatic void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec);static void extract_class_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec);-static void walk_defs(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, int depth);+static void walk_defs(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec, int depth_unused);static void extract_variables(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec);static void extract_class_variables(CBMExtractCtx *ctx, TSNode class_node, const CBMLangSpec *spec);static void extract_rust_impl(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec);@@ -40,7 +40,6 @@ static TSNode func_name_node(TSNode node) {}// Resolve the name node for a function, handling language-specific quirks-// NOLINTNEXTLINE(readability-function-cognitive-complexity,misc-no-recursion)static TSNode resolve_func_name(TSNode node, CBMLanguage lang, const char *source) {const char *kind = ts_node_type(node);@@ -1873,7 +1872,6 @@ static void extract_rust_impl(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec// --- Elixir def/defp/defmodule ----// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk for nested Elixir modulesstatic void extract_elixir_call(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {CBMArena *a = ctx->arena;@@ -1912,7 +1910,6 @@ static void extract_elixir_call(CBMExtractCtx *ctx, TSNode node, const CBMLangSpchar *name = NULL;if (strcmp(fk, "call") == 0 && ts_node_child_count(first_arg) > 0) {name = cbm_node_text(a, ts_node_child(first_arg, 0), ctx->source);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)} else if (strcmp(fk, "identifier") == 0) {name = cbm_node_text(a, first_arg, ctx->source);}@@ -1928,7 +1925,6 @@ static void extract_elixir_call(CBMExtractCtx *ctx, TSNode node, const CBMLangSpdef.file_path = ctx->rel_path;def.start_line = ts_node_start_point(node).row + 1;def.end_line = ts_node_end_point(node).row + 1;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)def.is_exported = (strcmp(macro, "def") == 0 || strcmp(macro, "defmacro") == 0);cbm_defs_push(&ctx->result->defs, a, def);} else if (strcmp(macro, "defmodule") == 0) {@@ -2564,7 +2560,6 @@ static void extract_var_names(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec// Recursive variable walker for languages with deeply nested module structure.// Used by YAML, TOML, INI, JSON (config languages with nested containers).-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk for nested config structuresstatic void walk_variables_rec(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec,int depth) {if (depth > 8) {@@ -2778,138 +2773,147 @@ static void extract_class_variables(CBMExtractCtx *ctx, TSNode class_node,// --- Module node + main walk ----// Recursive definition walker using tree-sitter cursor for cache-friendliness-// Search for nested class definitions inside a class body, recursing into wrapper-// nodes (field_declaration, template_declaration) but not into function bodies.-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk for nested class hierarchies-static void find_nested_classes(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {- uint32_t nc = ts_node_child_count(node);- for (uint32_t i = 0; i < nc; i++) {- TSNode child = ts_node_child(node, i);- if (cbm_kind_in_set(child, spec->class_node_types)) {- // Found a nested class — process it via normal walk_defs- walk_defs(ctx, child, spec, 0);- } else {- const char *ck = ts_node_type(child);- // Recurse into wrapper nodes that might contain nested classes- // but NOT into function bodies (function_definition, lambda_expression)- if (strcmp(ck, "field_declaration") == 0 || strcmp(ck, "template_declaration") == 0 ||- strcmp(ck, "declaration") == 0) {- find_nested_classes(ctx, child, spec);+// Iterative walk_defs — explicit stack with enclosing class context per frame.+typedef struct {+ TSNode node;+ const char *enclosing_class_qn; // saved context for class nesting+} walk_defs_frame_t;++#define CBM_WALK_DEFS_STACK_CAP 4096++// Push nested class nodes from a class body container onto the defs stack.+// Iteratively walks into wrapper nodes (field_declaration, template_declaration).+static void push_nested_class_nodes(TSNode body, const CBMLangSpec *spec, walk_defs_frame_t *stack,+ int *top, const char *enclosing_qn) {+ TSNode nc_stack[128];+ int nc_top = 0;+ nc_stack[nc_top++] = body;++ while (nc_top > 0) {+ TSNode cur = nc_stack[--nc_top];+ uint32_t nc = ts_node_child_count(cur);+ for (int i = (int)nc - 1; i >= 0; i--) {+ TSNode child = ts_node_child(cur, (uint32_t)i);+ if (cbm_kind_in_set(child, spec->class_node_types)) {+ if (*top < CBM_WALK_DEFS_STACK_CAP) {+ stack[(*top)++] = (walk_defs_frame_t){child, enclosing_qn};+ }+ } else {+ const char *ck = ts_node_type(child);+ if (strcmp(ck, "field_declaration") == 0 ||+ strcmp(ck, "template_declaration") == 0 || strcmp(ck, "declaration") == 0) {+ if (nc_top < 128) {+ nc_stack[nc_top++] = child;+ }+ }}}}}-/* Max AST recursion depth — prevents stack overflow on pathological files.- * 256 levels is far beyond any real code nesting; 896+ was observed on- * generated Linux kernel headers with deeply nested preprocessor output. */-#define CBM_WALK_DEFS_MAX_DEPTH 256+static void walk_defs(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec, int depth_unused) {+ (void)depth_unused;+ walk_defs_frame_t stack[CBM_WALK_DEFS_STACK_CAP];+ int top = 0;+ stack[top++] = (walk_defs_frame_t){root, ctx->enclosing_class_qn};-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk-static void walk_defs(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, int depth) {- if (depth >= CBM_WALK_DEFS_MAX_DEPTH) {- return;- }-- const char *kind = ts_node_type(node);+ while (top > 0) {+ walk_defs_frame_t frame = stack[--top];+ TSNode node = frame.node;+ ctx->enclosing_class_qn = frame.enclosing_class_qn;+ const char *kind = ts_node_type(node);- // Elixir: all defs are call nodes- if (ctx->language == CBM_LANG_ELIXIR && strcmp(kind, "call") == 0) {- extract_elixir_call(ctx, node, spec);- return;- }+ // Elixir: all defs are call nodes+ if (ctx->language == CBM_LANG_ELIXIR && strcmp(kind, "call") == 0) {+ extract_elixir_call(ctx, node, spec);+ continue;+ }- // Function types- if (cbm_kind_in_set(node, spec->function_node_types)) {- // C++/CUDA: template_declaration may wrap a class, not a function.- // Check if it contains a class_specifier/struct_specifier — if so, skip- // function extraction and fall through to class handling.- bool is_template_class = false;- if ((ctx->language == CBM_LANG_CPP || ctx->language == CBM_LANG_CUDA) &&- strcmp(kind, "template_declaration") == 0) {- uint32_t nc = ts_node_named_child_count(node);- for (uint32_t i = 0; i < nc; i++) {- const char *ck = ts_node_type(ts_node_named_child(node, i));- if (strcmp(ck, "class_specifier") == 0 || strcmp(ck, "struct_specifier") == 0 ||- strcmp(ck, "union_specifier") == 0) {- is_template_class = true;- break;+ // Function types+ if (cbm_kind_in_set(node, spec->function_node_types)) {+ bool is_template_class = false;+ if ((ctx->language == CBM_LANG_CPP || ctx->language == CBM_LANG_CUDA) &&+ strcmp(kind, "template_declaration") == 0) {+ uint32_t nc = ts_node_named_child_count(node);+ for (uint32_t i = 0; i < nc; i++) {+ const char *ck = ts_node_type(ts_node_named_child(node, i));+ if (strcmp(ck, "class_specifier") == 0 || strcmp(ck, "struct_specifier") == 0 ||+ strcmp(ck, "union_specifier") == 0) {+ is_template_class = true;+ break;+ }}}- }- if (!is_template_class) {- extract_func_def(ctx, node, spec);- // Wolfram: continue recursing — nested set_delayed inside Module/Block are valid defs- if (ctx->language != CBM_LANG_WOLFRAM) {- return; // don't recurse into function bodies for nested defs+ if (!is_template_class) {+ extract_func_def(ctx, node, spec);+ if (ctx->language != CBM_LANG_WOLFRAM) {+ continue; // don't push function body children+ }}}- // For template classes: fall through to class check or default recursion- }- // Rust impl blocks- if (ctx->language == CBM_LANG_RUST && strcmp(kind, "impl_item") == 0) {- extract_rust_impl(ctx, node, spec);- return;- }+ // Rust impl blocks+ if (ctx->language == CBM_LANG_RUST && strcmp(kind, "impl_item") == 0) {+ extract_rust_impl(ctx, node, spec);+ continue;+ }- // Class types- if (cbm_kind_in_set(node, spec->class_node_types)) {- const char *saved_enclosing = ctx->enclosing_class_qn;- extract_class_def(ctx, node, spec);- // extract_class_def computed class_qn; replicate to set enclosing for nested classes- {- TSNode name_node = ts_node_child_by_field_name(node, "name", 4);- if (ts_node_is_null(name_node) && ctx->language == CBM_LANG_OBJC) {- name_node = cbm_find_child_by_kind(node, "identifier");- }- if (ts_node_is_null(name_node) && ctx->language == CBM_LANG_SWIFT) {- name_node = cbm_find_child_by_kind(node, "type_identifier");- }- if (!ts_node_is_null(name_node)) {- char *cname = cbm_node_text(ctx->arena, name_node, ctx->source);- if (cname && cname[0]) {- if (saved_enclosing) {- ctx->enclosing_class_qn =- cbm_arena_sprintf(ctx->arena, "%s.%s", saved_enclosing, cname);- } else {- ctx->enclosing_class_qn =- cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, cname);+ // Class types+ if (cbm_kind_in_set(node, spec->class_node_types)) {+ const char *saved_enclosing = frame.enclosing_class_qn;+ extract_class_def(ctx, node, spec);+ // Compute new enclosing class QN for nested classes+ const char *new_enclosing = saved_enclosing;+ {+ TSNode name_node = ts_node_child_by_field_name(node, "name", 4);+ if (ts_node_is_null(name_node) && ctx->language == CBM_LANG_OBJC) {+ name_node = cbm_find_child_by_kind(node, "identifier");+ }+ if (ts_node_is_null(name_node) && ctx->language == CBM_LANG_SWIFT) {+ name_node = cbm_find_child_by_kind(node, "type_identifier");+ }+ if (!ts_node_is_null(name_node)) {+ char *cname = cbm_node_text(ctx->arena, name_node, ctx->source);+ if (cname && cname[0]) {+ if (saved_enclosing) {+ new_enclosing =+ cbm_arena_sprintf(ctx->arena, "%s.%s", saved_enclosing, cname);+ } else {+ new_enclosing =+ cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, cname);+ }}}}- }- // Recurse into class body for nested class definitions (C++, Java, C#, Python, etc.)- // For languages with body containers, use targeted nested class search.- // For config languages (XML, JSON, etc.) with no body container, generic child walk.- bool found_body = false;- uint32_t nc = ts_node_child_count(node);- for (uint32_t ci = 0; ci < nc; ci++) {- TSNode child = ts_node_child(node, ci);- const char *ck = ts_node_type(child);- if (strcmp(ck, "field_declaration_list") == 0 || strcmp(ck, "class_body") == 0 ||- strcmp(ck, "declaration_list") == 0 || strcmp(ck, "body") == 0 ||- strcmp(ck, "block") == 0 || strcmp(ck, "suite") == 0) {- find_nested_classes(ctx, child, spec);- found_body = true;- break;- }- }- if (!found_body) {- // Config languages (XML, TOML, JSON, etc.) — children are direct class nodes+ // Push nested class children with the new enclosing context+ bool found_body = false;+ uint32_t nc = ts_node_child_count(node);for (uint32_t ci = 0; ci < nc; ci++) {- walk_defs(ctx, ts_node_child(node, ci), spec, depth + 1);+ TSNode child = ts_node_child(node, ci);+ const char *ck = ts_node_type(child);+ if (strcmp(ck, "field_declaration_list") == 0 || strcmp(ck, "class_body") == 0 ||+ strcmp(ck, "declaration_list") == 0 || strcmp(ck, "body") == 0 ||+ strcmp(ck, "block") == 0 || strcmp(ck, "suite") == 0) {+ push_nested_class_nodes(child, spec, stack, &top, new_enclosing);+ found_body = true;+ break;+ }+ }+ if (!found_body) {+ for (int ci = (int)nc - 1; ci >= 0 && top < CBM_WALK_DEFS_STACK_CAP; ci--) {+ stack[top++] =+ (walk_defs_frame_t){ts_node_child(node, (uint32_t)ci), new_enclosing};+ }}+ continue;}- ctx->enclosing_class_qn = saved_enclosing;- return;- }- // Recurse into children- uint32_t count = ts_node_child_count(node);- for (uint32_t i = 0; i < count; i++) {- walk_defs(ctx, ts_node_child(node, i), spec, depth + 1);+ // Default: push all children (reverse order for left-to-right processing)+ uint32_t count = ts_node_child_count(node);+ for (int i = (int)count - 1; i >= 0 && top < CBM_WALK_DEFS_STACK_CAP; i--) {+ stack[top++] =+ (walk_defs_frame_t){ts_node_child(node, (uint32_t)i), frame.enclosing_class_qn};+ }}}diff --git a/internal/cbm/extract_env_accesses.c b/internal/cbm/extract_env_accesses.cindex 71389786e..0e73c242b 100644--- a/internal/cbm/extract_env_accesses.c+++ b/internal/cbm/extract_env_accesses.c@@ -131,55 +131,47 @@ static bool is_env_var_name(const char *s) {return has_upper;}-#define WALK_ENV_MAX_DEPTH 4096--// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk-static void walk_env_inner(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, int depth) {- if (depth > WALK_ENV_MAX_DEPTH) {- return;- }- const char *kind = ts_node_type(node);- const char *env_key = NULL;-- // Check call nodes- if (cbm_kind_in_set(node, spec->call_node_types)) {- env_key = extract_env_key_from_call(ctx, node, spec);- }- // Check member/subscript access- else if (strcmp(kind, "member_expression") == 0 || strcmp(kind, "subscript") == 0 ||- strcmp(kind, "attribute") == 0) {- env_key = extract_env_key_from_member(ctx, node, spec);- }+// Iterative env access walker — explicit stack+#define ENV_STACK_CAP 4096+static void walk_env_accesses(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) {+ TSNode stack[ENV_STACK_CAP];+ int top = 0;+ stack[top++] = root;++ while (top > 0) {+ TSNode node = stack[--top];+ const char *kind = ts_node_type(node);+ const char *env_key = NULL;++ if (cbm_kind_in_set(node, spec->call_node_types)) {+ env_key = extract_env_key_from_call(ctx, node, spec);+ } else if (strcmp(kind, "member_expression") == 0 || strcmp(kind, "subscript") == 0 ||+ strcmp(kind, "attribute") == 0) {+ env_key = extract_env_key_from_member(ctx, node, spec);+ }- if (env_key && env_key[0] && is_env_var_name(env_key)) {- CBMEnvAccess ea;- ea.env_key = env_key;- ea.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);- cbm_envaccess_push(&ctx->result->env_accesses, ctx->arena, ea);- // Don't recurse into this node's children (avoid double-counting)- return;- }+ if (env_key && env_key[0] && is_env_var_name(env_key)) {+ CBMEnvAccess ea;+ ea.env_key = env_key;+ ea.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);+ cbm_envaccess_push(&ctx->result->env_accesses, ctx->arena, ea);+ continue; // don't push children (avoid double-counting)+ }- // Recurse- uint32_t count = ts_node_child_count(node);- for (uint32_t i = 0; i < count; i++) {- walk_env_inner(ctx, ts_node_child(node, i), spec, depth + 1);+ uint32_t count = ts_node_child_count(node);+ for (int i = (int)count - 1; i >= 0 && top < ENV_STACK_CAP; i--) {+ stack[top++] = ts_node_child(node, (uint32_t)i);+ }}}-static void walk_env_accesses(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {- walk_env_inner(ctx, node, spec, 0);-}-void cbm_extract_env_accesses(CBMExtractCtx *ctx) {const CBMLangSpec *spec = cbm_lang_spec(ctx->language);if (!spec) {return;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion) — pointer-to-bool check for NULL arraybool has_funcs = spec->env_access_functions && spec->env_access_functions[0];- // NOLINTNEXTLINE(readability-implicit-bool-conversion) — pointer-to-bool check for NULL arraybool has_members = spec->env_access_member_patterns && spec->env_access_member_patterns[0];if (!has_funcs && !has_members) {return;@@ -192,9 +184,7 @@ void cbm_extract_env_accesses(CBMExtractCtx *ctx) {void handle_env_accesses(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec,WalkState *state) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion) — pointer-to-bool check for NULL arraybool has_funcs = spec->env_access_functions && spec->env_access_functions[0];- // NOLINTNEXTLINE(readability-implicit-bool-conversion) — pointer-to-bool check for NULL arraybool has_members = spec->env_access_member_patterns && spec->env_access_member_patterns[0];if (!has_funcs && !has_members) {return;diff --git a/internal/cbm/extract_imports.c b/internal/cbm/extract_imports.cindex 87f8021bf..8ba0b0836 100644--- a/internal/cbm/extract_imports.c+++ b/internal/cbm/extract_imports.c@@ -244,7 +244,6 @@ static void parse_python_imports(CBMExtractCtx *ctx) {// import X from "Y"; import {A, B} from "Y"; import * as X from "Y"// const X = require("Y")-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walkstatic void walk_es_imports(CBMExtractCtx *ctx, TSNode node) {CBMArena *a = ctx->arena;const char *kind = ts_node_type(node);@@ -668,7 +667,6 @@ static void parse_generic_imports(CBMExtractCtx *ctx, const char *node_type) {// get_top: << "package" (Get["file"])// apply where first child is builtin_symbol "Needs" with string arg-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walkstatic void walk_wolfram_imports(CBMExtractCtx *ctx, TSNode node) {CBMArena *a = ctx->arena;const char *kind = ts_node_type(node);diff --git a/internal/cbm/extract_semantic.c b/internal/cbm/extract_semantic.cindex 7f6861569..8244c4fb8 100644--- a/internal/cbm/extract_semantic.c+++ b/internal/cbm/extract_semantic.c@@ -12,35 +12,26 @@// --- Throw/Raise extraction ----// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk-static void walk_throws(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {+// Process a single node for throw extraction (called from iterative walker).+static void process_throw_node(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {const char *kind = ts_node_type(node);if (cbm_kind_in_set(node, spec->throw_node_types)) {- // Extract the exception namechar *exc_name = NULL;-- // Python raise: raise_statement -> first child is the exception- // Java throw: throw_statement -> first expression child- // JS throw: throw_statement -> first expression childuint32_t nc = ts_node_child_count(node);for (uint32_t i = 0; i < nc; i++) {TSNode child = ts_node_child(node, i);const char *ck = ts_node_type(child);- // Skip keywordsif (strcmp(ck, "raise") == 0 || strcmp(ck, "throw") == 0) {continue;}- // Skip semicolons and other punctuationif (ck[0] == ';' || ck[0] == '(' || ck[0] == ')') {continue;}-if (strcmp(ck, "call") == 0 || strcmp(ck, "call_expression") == 0 ||strcmp(ck, "new_expression") == 0 ||strcmp(ck, "object_creation_expression") == 0 ||strcmp(ck, "instance_expression") == 0) {- // Call/new: get the function/type nameTSNode fn = ts_node_child_by_field_name(child, "function", 8);if (ts_node_is_null(fn)) {fn = ts_node_child_by_field_name(child, "constructor", FIELD_LEN_CONSTRUCTOR);@@ -48,7 +39,6 @@ static void walk_throws(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *specif (ts_node_is_null(fn)) {fn = ts_node_child_by_field_name(child, "type", 4);}- // Fallback: first named child (skips 'new' keyword)if (ts_node_is_null(fn) && ts_node_named_child_count(child) > 0) {fn = ts_node_named_child(child, 0);}@@ -56,18 +46,14 @@ static void walk_throws(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *specexc_name = cbm_node_text(ctx->arena, fn, ctx->source);}} else {- // identifier, type_identifier, or any other expressionexc_name = cbm_node_text(ctx->arena, child, ctx->source);}break;}-if (exc_name && exc_name[0]) {- // Truncate long exception namesif (strlen(exc_name) > 100) {exc_name[100] = '\0';}-CBMThrow thr;thr.exception_name = exc_name;thr.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);@@ -75,14 +61,12 @@ static void walk_throws(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec}}- // Java: check for throws clause on function declarationsif (spec->throws_clause_field && spec->throws_clause_field[0]) {if (strcmp(kind, "method_declaration") == 0 ||strcmp(kind, "constructor_declaration") == 0) {TSNode throws_clause = ts_node_child_by_field_name(node, spec->throws_clause_field, (uint32_t)strlen(spec->throws_clause_field));if (!ts_node_is_null(throws_clause)) {- // Extract each exception type from the throws clauseuint32_t nc = ts_node_child_count(throws_clause);for (uint32_t i = 0; i < nc; i++) {TSNode child = ts_node_child(throws_clause, i);@@ -100,48 +84,58 @@ static void walk_throws(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec}}}+}- // Recurse- uint32_t count = ts_node_child_count(node);- for (uint32_t i = 0; i < count; i++) {- walk_throws(ctx, ts_node_child(node, i), spec);+// Iterative throw walker+#define THROWS_STACK_CAP 512+static void walk_throws(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) {+ TSNode stack[THROWS_STACK_CAP];+ int top = 0;+ stack[top++] = root;+ while (top > 0) {+ TSNode node = stack[--top];+ process_throw_node(ctx, node, spec);+ uint32_t count = ts_node_child_count(node);+ for (int i = (int)count - 1; i >= 0 && top < THROWS_STACK_CAP; i--) {+ stack[top++] = ts_node_child(node, (uint32_t)i);+ }}}-// --- Read/Write detection ---+// --- Read/Write detection (iterative) ----// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk-static void walk_readwrites(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {- // Check if this is an assignment node- if (cbm_kind_in_set(node, spec->assignment_node_types)) {- // Left side is a write, right side contains reads- TSNode left = ts_node_child_by_field_name(node, "left", 4);- if (ts_node_is_null(left)) {- // Try first child as left-hand side- if (ts_node_child_count(node) > 0) {- left = ts_node_child(node, 0);+#define READWRITE_STACK_CAP 512+static void walk_readwrites(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) {+ TSNode stack[READWRITE_STACK_CAP];+ int top = 0;+ stack[top++] = root;+ while (top > 0) {+ TSNode node = stack[--top];+ if (cbm_kind_in_set(node, spec->assignment_node_types)) {+ TSNode left = ts_node_child_by_field_name(node, "left", 4);+ if (ts_node_is_null(left)) {+ if (ts_node_child_count(node) > 0) {+ left = ts_node_child(node, 0);+ }}- }-- if (!ts_node_is_null(left)) {- const char *lk = ts_node_type(left);- if (strcmp(lk, "identifier") == 0 || strcmp(lk, "simple_identifier") == 0) {- char *name = cbm_node_text(ctx->arena, left, ctx->source);- if (name && name[0] && !cbm_is_keyword(name, ctx->language)) {- CBMReadWrite rw;- rw.var_name = name;- rw.is_write = true;- rw.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);- cbm_rw_push(&ctx->result->rw, ctx->arena, rw);+ if (!ts_node_is_null(left)) {+ const char *lk = ts_node_type(left);+ if (strcmp(lk, "identifier") == 0 || strcmp(lk, "simple_identifier") == 0) {+ char *name = cbm_node_text(ctx->arena, left, ctx->source);+ if (name && name[0] && !cbm_is_keyword(name, ctx->language)) {+ CBMReadWrite rw;+ rw.var_name = name;+ rw.is_write = true;+ rw.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);+ cbm_rw_push(&ctx->result->rw, ctx->arena, rw);+ }}}}- }-- // Recurse- uint32_t count = ts_node_child_count(node);- for (uint32_t i = 0; i < count; i++) {- walk_readwrites(ctx, ts_node_child(node, i), spec);+ uint32_t count = ts_node_child_count(node);+ for (int i = (int)count - 1; i >= 0 && top < READWRITE_STACK_CAP; i--) {+ stack[top++] = ts_node_child(node, (uint32_t)i);+ }}}@@ -166,9 +160,7 @@ void cbm_extract_semantic(CBMExtractCtx *ctx) {// --- Unified handlers ---void handle_throws(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, WalkState *state) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion) — pointer-to-bool check for NULL arraybool has_throws = spec->throw_node_types && spec->throw_node_types[0];- // NOLINTNEXTLINE(readability-implicit-bool-conversion) — pointer-to-bool check for NULL arraybool has_clause = spec->throws_clause_field && spec->throws_clause_field[0];if (!has_throws && !has_clause) {return;diff --git a/internal/cbm/extract_type_assigns.c b/internal/cbm/extract_type_assigns.cindex 5caf6aab8..0b0898306 100644--- a/internal/cbm/extract_type_assigns.c+++ b/internal/cbm/extract_type_assigns.c@@ -77,7 +77,6 @@ static const char *extract_constructor_type(CBMArena *a, TSNode rhs, const char}// Walk AST for assignment patterns where RHS is a constructor call.-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walkstatic void walk_type_assigns(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {const char *kind = ts_node_type(node);diff --git a/internal/cbm/extract_type_refs.c b/internal/cbm/extract_type_refs.cindex ffedd0223..c26b59bb1 100644--- a/internal/cbm/extract_type_refs.c+++ b/internal/cbm/extract_type_refs.c@@ -66,7 +66,6 @@ static const char *clean_type_name(CBMArena *a, const char *name) {}// Extract type name from a type annotation node.-// NOLINTNEXTLINE(misc-no-recursion)static const char *extract_type_text(CBMArena *a, TSNode node, const char *source) {const char *kind = ts_node_type(node);// For type_identifier / identifier, just get text@@ -98,7 +97,6 @@ static const char *extract_type_text(CBMArena *a, TSNode node, const char *sourc}// Add a type reference for a function.-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void add_type_ref(CBMExtractCtx *ctx, const char *type_name, const char *func_qn) {if (!type_name || !type_name[0]) {return;@@ -144,7 +142,6 @@ static void extract_return_type_refs(CBMExtractCtx *ctx, TSNode func_node, const}// Walk function body for type references (casts, type assertions, local var types, generics).-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walkstatic void walk_body_type_refs(CBMExtractCtx *ctx, TSNode node, const char *func_qn) {const char *kind = ts_node_type(node);@@ -242,7 +239,6 @@ static void walk_body_type_refs(CBMExtractCtx *ctx, TSNode node, const char *fun}// Walk AST for function nodes, extract type references from signatures and bodies.-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walkstatic void walk_type_refs(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {if (!spec->function_node_types || !spec->function_node_types[0]) {return;diff --git a/internal/cbm/extract_unified.c b/internal/cbm/extract_unified.cindex 940d719b7..d10bcf23d 100644--- a/internal/cbm/extract_unified.c+++ b/internal/cbm/extract_unified.c@@ -9,7 +9,6 @@// --- Scope stack management ----// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void push_scope(WalkState *state, uint8_t kind, uint32_t depth, const char *qn) {if (state->scope_top >= MAX_SCOPES) {return;@@ -196,7 +195,6 @@ static void handle_string_constants(CBMExtractCtx *ctx, TSNode node, const WalkSstatic bool is_string_node(const char *kind) {/* Common string literal node types across tree-sitter grammars */- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (strcmp(kind, "string_literal") == 0 || strcmp(kind, "string") == 0 ||strcmp(kind, "string_content") == 0 ||strcmp(kind, "interpreted_string_literal") == 0 ||diff --git a/internal/cbm/extract_usages.c b/internal/cbm/extract_usages.cindex 84a35fd3d..8ad3b6ff6 100644--- a/internal/cbm/extract_usages.c+++ b/internal/cbm/extract_usages.c@@ -8,7 +8,7 @@#include <ctype.h>// Forward declaration-static void walk_usages(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec);+static void walk_usages(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec);// Check if a node is inside a call expression (to avoid double-counting as usage)static bool is_inside_call(TSNode node, const CBMLangSpec *spec) {@@ -54,75 +54,64 @@ static bool is_reference_node(TSNode node, CBMLanguage lang) {// Language-specific reference typesswitch (lang) {case CBM_LANG_GO:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return strcmp(kind, "field_identifier") == 0 || strcmp(kind, "package_identifier") == 0;case CBM_LANG_PYTHON:return strcmp(kind, "attribute") == 0;case CBM_LANG_RUST:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return strcmp(kind, "field_identifier") == 0 || strcmp(kind, "scoped_identifier") == 0;case CBM_LANG_HASKELL:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return strcmp(kind, "variable") == 0 || strcmp(kind, "constructor") == 0;case CBM_LANG_OCAML:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return strcmp(kind, "value_path") == 0 || strcmp(kind, "constructor_path") == 0;case CBM_LANG_ERLANG:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return strcmp(kind, "atom") == 0 || strcmp(kind, "var") == 0;default:return false;}}-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk-/* Max recursion depth — prevents stack overflow on deeply nested C++ templates.- * 8MB stack / ~256 bytes per frame ≈ 32K max, use 4K as safe limit. */-#define WALK_USAGES_MAX_DEPTH 4096+// Iterative usage walker — explicit stack+#define USAGES_STACK_CAP 4096+static void walk_usages(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) {+ TSNode stack[USAGES_STACK_CAP];+ int top = 0;+ stack[top++] = root;-static void walk_usages_inner(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, int depth) {- if (depth > WALK_USAGES_MAX_DEPTH) {- return;- }- if (is_reference_node(node, ctx->language)) {- // Skip if inside a call (already counted as CALLS edge)- if (is_inside_call(node, spec)) {- goto recurse;- }- // Skip if inside an import- if (is_inside_import(node, spec)) {- goto recurse;- }- // Skip if it's a definition name (left side of assignment, function name)- TSNode parent = ts_node_parent(node);- if (!ts_node_is_null(parent)) {- // Check if this is the "name" field of the parent- TSNode name_field = ts_node_child_by_field_name(parent, "name", 4);- if (!ts_node_is_null(name_field) &&- ts_node_start_byte(name_field) == ts_node_start_byte(node) &&- ts_node_end_byte(name_field) == ts_node_end_byte(node)) {- goto recurse;+ while (top > 0) {+ TSNode node = stack[--top];++ if (is_reference_node(node, ctx->language)) {+ bool skip = false;+ if (is_inside_call(node, spec) || is_inside_import(node, spec)) {+ skip = true;+ }+ if (!skip) {+ TSNode parent = ts_node_parent(node);+ if (!ts_node_is_null(parent)) {+ TSNode name_field = ts_node_child_by_field_name(parent, "name", 4);+ if (!ts_node_is_null(name_field) &&+ ts_node_start_byte(name_field) == ts_node_start_byte(node) &&+ ts_node_end_byte(name_field) == ts_node_end_byte(node)) {+ skip = true;+ }+ }+ }+ if (!skip) {+ char *name = cbm_node_text(ctx->arena, node, ctx->source);+ if (name && name[0] && !cbm_is_keyword(name, ctx->language)) {+ CBMUsage usage;+ usage.ref_name = name;+ usage.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);+ cbm_usages_push(&ctx->result->usages, ctx->arena, usage);+ }}}- char *name = cbm_node_text(ctx->arena, node, ctx->source);- if (name && name[0] && !cbm_is_keyword(name, ctx->language)) {- CBMUsage usage;- usage.ref_name = name;- usage.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node);- cbm_usages_push(&ctx->result->usages, ctx->arena, usage);+ uint32_t count = ts_node_child_count(node);+ for (int i = (int)count - 1; i >= 0 && top < USAGES_STACK_CAP; i--) {+ stack[top++] = ts_node_child(node, (uint32_t)i);}}--recurse:;- uint32_t count = ts_node_child_count(node);- for (uint32_t i = 0; i < count; i++) {- walk_usages_inner(ctx, ts_node_child(node, i), spec, depth + 1);- }-}--static void walk_usages(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {- walk_usages_inner(ctx, node, spec, 0);}void cbm_extract_usages(CBMExtractCtx *ctx) {diff --git a/internal/cbm/helpers.c b/internal/cbm/helpers.cindex c3d9b16da..5ecfd9ca1 100644--- a/internal/cbm/helpers.c+++ b/internal/cbm/helpers.c@@ -141,14 +141,12 @@ bool cbm_is_exported(const char *name, CBMLanguage lang) {}switch (lang) {case CBM_LANG_GO:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (name[0] >= 'A' && name[0] <= 'Z');case CBM_LANG_PYTHON:return (name[0] != '_');case CBM_LANG_JAVA:case CBM_LANG_CSHARP:case CBM_LANG_KOTLIN:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (name[0] >= 'A' && name[0] <= 'Z');default:return true;@@ -201,14 +199,12 @@ bool cbm_is_test_file(const char *rel_path, CBMLanguage lang) {case CBM_LANG_GO:return has_suffix(base, "_test.go");case CBM_LANG_PYTHON:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_prefix(base, "test_") || has_suffix(base, "_test.py");case CBM_LANG_JAVASCRIPT:case CBM_LANG_TYPESCRIPT:case CBM_LANG_TSX: {char noext[256];strip_ext(base, noext, sizeof(noext));- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_suffix(noext, ".test") || has_suffix(noext, ".spec") ||has_suffix(noext, "_test") || has_suffix(noext, "_spec") ||has_prefix(base, "test_");@@ -216,31 +212,25 @@ bool cbm_is_test_file(const char *rel_path, CBMLanguage lang) {case CBM_LANG_JAVA:case CBM_LANG_KOTLIN:case CBM_LANG_SCALA:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_suffix(base, "Test.java") || has_suffix(base, "Tests.java") ||has_suffix(base, "Spec.java") || has_suffix(base, "Test.kt") ||has_suffix(base, "Spec.kt") || has_suffix(base, "Test.scala") ||has_suffix(base, "Spec.scala");case CBM_LANG_RUST:// Rust tests are typically mod tests inside the file, but test files too- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_suffix(base, "_test.rs") || has_prefix(base, "test_");case CBM_LANG_RUBY:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_suffix(base, "_test.rb") || has_suffix(base, "_spec.rb") ||has_prefix(base, "test_");case CBM_LANG_PHP:return has_suffix(base, "Test.php");case CBM_LANG_CSHARP:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_suffix(base, "Tests.cs") || has_suffix(base, "Test.cs");case CBM_LANG_CPP:case CBM_LANG_C:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_suffix(base, "_test.c") || has_suffix(base, "_test.cc") ||has_suffix(base, "_test.cpp") || has_prefix(base, "test_");case CBM_LANG_MATLAB:- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_prefix(base, "test_") || has_prefix(base, "Test");default:return false;@@ -290,7 +280,6 @@ bool cbm_has_ancestor_kind(TSNode node, const char *kind, int max_depth) {}// Recursive branching count-// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walkstatic int count_branching_rec(TSNode node, const char **types) {int count = 0;const char *kind = ts_node_type(node);@@ -411,7 +400,6 @@ TSNode cbm_find_enclosing_func(TSNode node, CBMLanguage lang) {break;}const char *pk = ts_node_type(parent);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)for (const char **k = kinds; *k; k++) {if (strcmp(pk, *k) == 0) {return parent;@@ -461,9 +449,7 @@ static const char *func_node_name(CBMArena *a, TSNode func_node, const char *soureturn NULL;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)const char *cbm_enclosing_func_qn(CBMArena *a, TSNode node, CBMLanguage lang, const char *source,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)const char *project, const char *rel_path,const char *module_qn) {TSNode func_node = cbm_find_enclosing_func(node, lang);@@ -573,7 +559,6 @@ bool cbm_is_module_level(TSNode node, CBMLanguage lang) {}if (strcmp(pk, "expression_statement") == 0) {TSNode gp = ts_node_parent(parent);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return !ts_node_is_null(gp) && strcmp(ts_node_type(gp), "module") == 0;}return false;@@ -586,7 +571,6 @@ bool cbm_is_module_level(TSNode node, CBMLanguage lang) {}if (strcmp(pk, "export_statement") == 0) {TSNode gp = ts_node_parent(parent);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return !ts_node_is_null(gp) && strcmp(ts_node_type(gp), "program") == 0;}return false;@@ -600,7 +584,6 @@ bool cbm_is_module_level(TSNode node, CBMLanguage lang) {// assignment_statement -> chunkif (strcmp(pk, "assignment_statement") == 0) {TSNode gp = ts_node_parent(parent);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return !ts_node_is_null(gp) && strcmp(ts_node_type(gp), "chunk") == 0;}return false;@@ -608,7 +591,6 @@ bool cbm_is_module_level(TSNode node, CBMLanguage lang) {// YAML: document or streamif (lang == CBM_LANG_YAML) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return strcmp(pk, "document") == 0 || strcmp(pk, "stream") == 0 ||strcmp(pk, "block_mapping") == 0;}@@ -720,7 +702,6 @@ bool cbm_is_module_level(TSNode node, CBMLanguage lang) {return false;}if (parents) {- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)for (const char **p = parents; *p; p++) {if (strcmp(pk, *p) == 0) {return true;@@ -935,7 +916,6 @@ static bool is_env_var_pattern(const char *s, int len) {return false;}}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_upper && has_underscore;}diff --git a/internal/cbm/sqlite_writer.c b/internal/cbm/sqlite_writer.cindex f361ea192..a94f21f83 100644--- a/internal/cbm/sqlite_writer.c+++ b/internal/cbm/sqlite_writer.c@@ -168,7 +168,6 @@ static int int_storage_bytes(int serial_type) {}// Write integer in big-endian for given byte count-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void put_int_be(uint8_t *buf, int64_t val, int nbytes) {for (int i = nbytes - 1; i >= 0; i--) {buf[i] = (uint8_t)(val & BYTE_MASK);@@ -214,7 +213,6 @@ static bool dynbuf_ensure(DynBuf *b, int needed) {}uint8_t *p = (uint8_t *)realloc(b->data, newcap);if (!p) {- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,cert-err33-c)fprintf(stderr, "cbm_write_db: dynbuf realloc failed size=%d\n", newcap);return false;}@@ -380,7 +378,6 @@ static void pb_flush_leaf(PageBuilder *pb) {int hdr = pb->page1_offset;// Write leaf page header- // NOLINTNEXTLINE(readability-implicit-bool-conversion)pb->page[hdr + 0] = pb->is_index ? BTREE_LEAF_INDEX : BTREE_LEAF_TABLE; // leaf flagput_u16(pb->page + hdr + 1, 0); // first freeblockput_u16(pb->page + hdr + 3, (uint16_t)pb->cell_count);@@ -390,9 +387,7 @@ static void pb_flush_leaf(PageBuilder *pb) {// Write page to fileuint32_t page_num = pb->next_page;long offset = (long)(page_num - 1) * PAGE_SIZE;- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefseek(pb->fp, offset, SEEK_SET);- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefwrite(pb->page, 1, PAGE_SIZE, pb->fp);// Record this leaf for interior page building@@ -555,7 +550,6 @@ static uint32_t pb_build_interior(PageBuilder *pb, bool is_index) {// Write the interior pageuint32_t pnum = pb->next_page++;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)page[0] = is_index ? 0x02 : 0x05;put_u16(page + 1, 0);put_u16(page + 3, (uint16_t)cell_count);@@ -563,9 +557,7 @@ static uint32_t pb_build_interior(PageBuilder *pb, bool is_index) {page[7] = 0;put_u32(page + 8, right_child_page);- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefseek(pb->fp, (long)(pnum - 1) * PAGE_SIZE, SEEK_SET);- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefwrite(page, 1, PAGE_SIZE, pb->fp);// Record this interior page as a parent for the next level@@ -842,7 +834,6 @@ static void pb_ensure_leaf_cap(PageBuilder *pb) {// Add a table cell to the PageBuilder, flushing leaf pages as needed.static void pb_add_table_cell_with_flush(PageBuilder *pb, int64_t rowid, const uint8_t *payload,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int payload_len, int64_t prev_rowid) {int cell_len = 0;uint8_t *cell = build_table_cell(rowid, payload, payload_len, &cell_len);@@ -904,23 +895,19 @@ static uint32_t write_table_btree(FILE *fp, uint32_t *next_page, const uint8_t *uint32_t pnum = (*next_page)++;uint8_t page[PAGE_SIZE];memset(page, 0, PAGE_SIZE);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)int hdr = first_is_page1 ? 100 : 0;page[hdr] = BTREE_LEAF_TABLE; // leaf tableput_u16(page + hdr + 1, 0); // no freeblocksput_u16(page + hdr + 3, 0); // 0 cellsput_u16(page + hdr + 5, (uint16_t)PAGE_SIZE); // content at end of pagepage[hdr + 7] = 0; // 0 fragmented bytes- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefseek(fp, (long)(pnum - 1) * PAGE_SIZE, SEEK_SET);- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefwrite(page, 1, PAGE_SIZE, fp);return pnum;}PageBuilder pb;pb_init(&pb, fp, *next_page, false);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)pb.page1_offset = first_is_page1 ? 100 : 0;pb.ptr_offset = pb.page1_offset + 8;@@ -944,9 +931,7 @@ static uint32_t write_index_btree(FILE *fp, uint32_t *next_page, uint8_t **cellsput_u16(page + 3, 0); // 0 cellsput_u16(page + 5, (uint16_t)PAGE_SIZE); // content at end of pagepage[7] = 0; // 0 fragmented bytes- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefseek(fp, (long)(pnum - 1) * PAGE_SIZE, SEEK_SET);- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefwrite(page, 1, PAGE_SIZE, fp);return pnum;}@@ -1072,7 +1057,6 @@ static inline const char *safe_str(const char *s) {static int *make_sorted_perm(int n, int (*cmp)(const void *, const void *)) {int *perm = (int *)malloc(n * sizeof(int));if (!perm) {- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,cert-err33-c)fprintf(stderr, "cbm_write_db: perm malloc failed n=%d size=%zu\n", n,(size_t)n * sizeof(int));return NULL;@@ -1086,7 +1070,6 @@ static int *make_sorted_perm(int n, int (*cmp)(const void *, const void *)) {// --- Node index comparators (project is same for all, skip it) ----// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_node_by_label(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1097,7 +1080,6 @@ static int cmp_node_by_label(const void *a, const void *b) {return cmp_i64(g_sort_nodes[ia].id, g_sort_nodes[ib].id);}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_node_by_name(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1108,7 +1090,6 @@ static int cmp_node_by_name(const void *a, const void *b) {return cmp_i64(g_sort_nodes[ia].id, g_sort_nodes[ib].id);}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_node_by_file(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1119,7 +1100,6 @@ static int cmp_node_by_file(const void *a, const void *b) {return cmp_i64(g_sort_nodes[ia].id, g_sort_nodes[ib].id);}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_node_by_qn(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1134,7 +1114,6 @@ static int cmp_node_by_qn(const void *a, const void *b) {// --- Edge index comparators ---// idx_edges_source: (source_id, type) + rowid-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_edge_by_source_type(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1150,7 +1129,6 @@ static int cmp_edge_by_source_type(const void *a, const void *b) {}// idx_edges_target: (target_id, type) + rowid-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_edge_by_target_type(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1166,7 +1144,6 @@ static int cmp_edge_by_target_type(const void *a, const void *b) {}// idx_edges_type: (project, type) + rowid-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_edge_by_type(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1178,7 +1155,6 @@ static int cmp_edge_by_type(const void *a, const void *b) {}// idx_edges_target_type: (project, target_id, type) + rowid-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_edge_by_proj_target_type(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1194,7 +1170,6 @@ static int cmp_edge_by_proj_target_type(const void *a, const void *b) {}// idx_edges_source_type: (project, source_id, type) + rowid-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_edge_by_proj_source_type(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1210,16 +1185,13 @@ static int cmp_edge_by_proj_source_type(const void *a, const void *b) {}// idx_edges_url_path: (project, url_path_gen) + rowid — NULL sorts first-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_edge_by_url_path(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;const char *ua = g_sort_edges[ia].url_path;const char *ub = g_sort_edges[ib].url_path;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)- bool na = (!ua || !ua[0]);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)- bool nb = (!ub || !ub[0]);+ bool na = (!ua || ua[0] == '\0');+ bool nb = (!ub || ub[0] == '\0');if (na && nb) {return cmp_i64(g_sort_edges[ia].id, g_sort_edges[ib].id);}@@ -1237,7 +1209,6 @@ static int cmp_edge_by_url_path(const void *a, const void *b) {}// autoindex_edges_1: UNIQUE(source_id, target_id, type) + rowid-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_edge_by_src_tgt_type(const void *a, const void *b) {int ia = *(const int *)a;int ib = *(const int *)b;@@ -1272,7 +1243,7 @@ static void *sort_worker(void *arg) {// --- Main entry point ----// NOLINTNEXTLINE(bugprone-easily-swappable-parameters,readability-function-cognitive-complexity,readability-function-size)+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)int cbm_write_db(const char *path, const char *project, const char *root_path,const char *indexed_at, CBMDumpNode *nodes, int node_count, CBMDumpEdge *edges,int edge_count) {@@ -1294,7 +1265,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,int rec_len;uint8_t *rec = build_node_record(&nodes[i], &rec_len);if (!rec) {- // NOLINTNEXTLINE(cert-err33-c) — best-effort cleanup on error pathfclose(fp);return -3;}@@ -1317,7 +1287,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,int rec_len;uint8_t *rec = build_edge_record(&edges[i], &rec_len);if (!rec) {- // NOLINTNEXTLINE(cert-err33-c) — best-effort cleanup on error pathfclose(fp);return -3;}@@ -1465,20 +1434,16 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,} while (0)uint32_t idx_nodes_label_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_NODE_2TEXT_INDEX_SORTED(nodes[si].label, nsorts[0].perm, idx_nodes_label_root);uint32_t idx_nodes_name_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_NODE_2TEXT_INDEX_SORTED(nodes[si].name, nsorts[1].perm, idx_nodes_name_root);uint32_t idx_nodes_file_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_NODE_2TEXT_INDEX_SORTED(nodes[si].file_path ? nodes[si].file_path : "", nsorts[2].perm,idx_nodes_file_root);uint32_t autoindex_nodes_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_NODE_2TEXT_INDEX_SORTED(nodes[si].qualified_name, nsorts[3].perm, autoindex_nodes_root);#undef BUILD_NODE_2TEXT_INDEX_SORTED@@ -1531,7 +1496,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,// idx_edges_source: (source_id, type) + rowiduint32_t idx_edges_source_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_EDGE_INDEX_SORTED(esorts[0].perm,idx_cells[i] = build_index_entry_int_text_rowid(edges[si].source_id, edges[si].type, edges[si].id, &idx_lens[i]),@@ -1539,7 +1503,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,// idx_edges_target: (target_id, type) + rowiduint32_t idx_edges_target_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_EDGE_INDEX_SORTED(esorts[1].perm,idx_cells[i] = build_index_entry_int_text_rowid(edges[si].target_id, edges[si].type, edges[si].id, &idx_lens[i]),@@ -1547,7 +1510,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,// idx_edges_type: (project, type) + rowiduint32_t idx_edges_type_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_EDGE_INDEX_SORTED(esorts[2].perm,idx_cells[i] = build_index_entry_2text_rowid(edges[si].project, edges[si].type, edges[si].id, &idx_lens[i]),@@ -1555,7 +1517,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,// idx_edges_target_type: (project, target_id, type) + rowiduint32_t idx_edges_target_type_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_EDGE_INDEX_SORTED(esorts[3].perm,idx_cells[i] = build_index_entry_text_int_text_rowid(@@ -1564,7 +1525,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,// idx_edges_source_type: (project, source_id, type) + rowiduint32_t idx_edges_source_type_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_EDGE_INDEX_SORTED(esorts[4].perm,idx_cells[i] = build_index_entry_text_int_text_rowid(@@ -1607,7 +1567,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,for (int i = 0; i < edge_count; i++) {free(idx_cells[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(idx_cells);free(idx_lens);} else {@@ -1616,7 +1575,6 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,// Autoindex for UNIQUE(source_id, target_id, type) on edgesuint32_t autoindex_edges_root;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,BUILD_EDGE_INDEX_SORTED(esorts[6].perm,idx_cells[i] = build_index_entry_unique_2int_text_rowid(@@ -1758,11 +1716,9 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,for (int j = 0; j < master_count; j++) {free((void *)master_records[j]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(master_records);free(master_lens);free(master_rowids);- // NOLINTNEXTLINE(cert-err33-c) — best-effort cleanup on error pathfclose(fp);return -2;}@@ -1808,36 +1764,29 @@ int cbm_write_db(const char *path, const char *project, const char *root_path,// Set file change counter = version-valid-for = 1put_u32(page1 + HDR_OFF_FILE_CHANGE, 1);- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefseek(fp, 0, SEEK_SET);- // NOLINTNEXTLINE(cert-err33-c) — best-effort page write, errors detected at fclosefwrite(page1, 1, PAGE_SIZE, fp);}for (int i = 0; i < master_count; i++) {free((void *)master_records[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(master_records);free(master_lens);free(master_rowids);// Ensure file size is exactly next_page * PAGE_SIZE// (pad any remaining space)- // NOLINTNEXTLINE(cert-err33-c) — best-effort file positioningfseek(fp, 0, SEEK_END);long file_size = ftell(fp);long expected_size = (long)(next_page - 1) * PAGE_SIZE;if (file_size < expected_size) {// Pad with zerosuint8_t zero = 0;- // NOLINTNEXTLINE(cert-err33-c) — best-effort padding writefseek(fp, expected_size - 1, SEEK_SET);- // NOLINTNEXTLINE(cert-err33-c) — best-effort padding writefwrite(&zero, 1, 1, fp);}- // NOLINTNEXTLINE(cert-err33-c) — caller checks return code from this function, not fclosefclose(fp);return 0;}diff --git a/src/cli/cli.c b/src/cli/cli.cindex fb965d9b7..f5652d1f2 100644--- a/src/cli/cli.c+++ b/src/cli/cli.c@@ -130,7 +130,6 @@ const char *cbm_detect_shell_rc(const char *home_dir) {return "";}- // NOLINTNEXTLINE(concurrency-mt-unsafe)const char *shell = getenv("SHELL");if (!shell) {shell = "";@@ -169,18 +168,15 @@ const char *cbm_find_cli(const char *name, const char *home_dir) {}/* Check PATH first */- // NOLINTNEXTLINE(concurrency-mt-unsafe)const char *path_env = getenv("PATH");if (path_env) {char path_copy[4096];snprintf(path_copy, sizeof(path_copy), "%s", path_env);char *saveptr;- // NOLINTNEXTLINE(misc-include-cleaner) — strtok_r provided by standard headerchar *dir = strtok_r(path_copy, ":", &saveptr);while (dir) {snprintf(buf, sizeof(buf), "%s/%s", dir, name);struct stat st;- // NOLINTNEXTLINE(misc-include-cleaner) — S_IXUSR provided by standard headerif (stat(buf, &st) == 0 && (st.st_mode & S_IXUSR)) {return buf;}@@ -459,7 +455,6 @@ static int mkdirp(const char *path, int mode) {/* ── Recursive rmdir ──────────────────────────────────────────── */-// NOLINTNEXTLINE(misc-no-recursion) — intentional recursive directory removalstatic int rmdir_recursive(const char *path) {cbm_dir_t *d = cbm_opendir(path);if (!d) {@@ -593,7 +588,6 @@ static yyjson_doc *read_json_file(const char *path) {size_t nread = fread(buf, 1, (size_t)size, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';/* Allow JSONC (comments + trailing commas) — Zed settings.json uses this format */@@ -1573,6 +1567,72 @@ static void cbm_install_hook_gate_script(const char *home) {#endif}+/* SessionStart hook: remind agent to use MCP tools on every context reset. */+#define CMM_SESSION_COMMAND "~/.claude/hooks/cbm-session-reminder"++static void cbm_install_session_reminder_script(const char *home) {+ if (!home) {+ return;+ }+ char hooks_dir[1024];+ snprintf(hooks_dir, sizeof(hooks_dir), "%s/.claude/hooks", home);+ cbm_mkdir_p(hooks_dir, 0755);++ char script_path[1024];+ snprintf(script_path, sizeof(script_path), "%s/cbm-session-reminder", hooks_dir);++ FILE *f = fopen(script_path, "w");+ if (!f) {+ return;+ }+ fprintf(f,+ "#!/bin/bash\n"+ "# SessionStart hook: remind agent to use codebase-memory-mcp tools.\n"+ "# Installed by codebase-memory-mcp. Fires on startup/resume/clear/compact.\n"+ "cat << 'REMINDER'\n"+ "CRITICAL - Code Discovery Protocol:\n"+ "1. ALWAYS use codebase-memory-mcp tools FIRST for ANY code exploration:\n"+ " - search_graph(name_pattern/label/qn_pattern) to find functions/classes/routes\n"+ " - trace_path(function_name, mode=calls|data_flow|cross_service) for call chains\n"+ " - get_code_snippet(qualified_name) to read source (NOT Read/cat)\n"+ " - query_graph(query) for complex Cypher patterns\n"+ " - get_architecture(aspects) for project structure\n"+ " - search_code(pattern) for text search (graph-augmented grep)\n"+ "2. Fall back to Grep/Glob/Read ONLY for text content, config values, non-code files.\n"+ "3. If a project is not indexed yet, run index_repository FIRST.\n"+ "REMINDER\n");+#ifndef _WIN32+ fchmod(fileno(f), 0755);+#endif+ fclose(f);+#ifdef _WIN32+ chmod(script_path, 0755);+#endif+}++static int cbm_upsert_session_hooks(const char *settings_path) {+ static const char *matchers[] = {"startup", "resume", "clear", "compact"};+ int rc = 0;+ for (int i = 0; i < 4; i++) {+ if (upsert_hooks_json(settings_path, "SessionStart", matchers[i], CMM_SESSION_COMMAND) !=+ 0) {+ rc = -1;+ }+ }+ return rc;+}++static int cbm_remove_session_hooks(const char *settings_path) {+ static const char *matchers[] = {"startup", "resume", "clear", "compact"};+ int rc = 0;+ for (int i = 0; i < 4; i++) {+ if (remove_hooks_json(settings_path, "SessionStart", matchers[i]) != 0) {+ rc = -1;+ }+ }+ return rc;+}+#define GEMINI_HOOK_MATCHER "google_search|read_file|grep_search"#define GEMINI_HOOK_COMMAND \"echo 'Reminder: prefer codebase-memory-mcp search_graph/trace_path/" \@@ -1618,7 +1678,6 @@ int cbm_ensure_path(const char *bin_dir, const char *rc_file, bool dry_run) {return -1;}- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)(void)fprintf(f, "\n# Added by codebase-memory-mcp install\n%s\n", line);(void)fclose(f);return 0;@@ -1634,11 +1693,9 @@ unsigned char *cbm_extract_binary_from_targz(const unsigned char *data, int data/* Decompress gzip */z_stream strm = {0};- // NOLINTNEXTLINE(performance-no-int-to-ptr)strm.next_in = (unsigned char *)(uintptr_t)data;strm.avail_in = (unsigned int)data_len;- // NOLINTNEXTLINE(misc-include-cleaner) — MAX_WBITS provided by standard headerif (inflateInit2(&strm, 16 + MAX_WBITS) != Z_OK) {return NULL;}@@ -2198,7 +2255,6 @@ static bool prompt_yn(const char *question) {if (!fgets(buf, sizeof(buf), stdin)) {return false;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (buf[0] == 'y' || buf[0] == 'Y') ? true : false;}@@ -2222,7 +2278,6 @@ static int sha256_file(const char *path, char *out, size_t out_size) {#elsesnprintf(cmd, sizeof(cmd), "sha256sum '%s' 2>/dev/null", path);#endif- // NOLINTNEXTLINE(bugprone-command-processor,cert-env33-c)FILE *fp = cbm_popen(cmd, "r");if (!fp) {return -1;@@ -2307,7 +2362,6 @@ static int verify_download_checksum(const char *archive_path, const char *archivchar checksum_file[256];snprintf(checksum_file, sizeof(checksum_file), "%s/cbm-checksums.txt", cbm_tmpdir());- // NOLINTNEXTLINE(concurrency-mt-unsafe)const char *dl_base = getenv("CBM_DOWNLOAD_URL");char checksum_url[512];if (dl_base && dl_base[0]) {@@ -2459,8 +2513,11 @@ static void cbm_install_agent_configs(const char *home, const char *binary_path,if (!dry_run) {cbm_upsert_claude_hooks(settings_path);cbm_install_hook_gate_script(home);+ cbm_install_session_reminder_script(home);+ cbm_upsert_session_hooks(settings_path);}printf(" hooks: PreToolUse (code discovery gate)\n");+ printf(" hooks: SessionStart (MCP usage reminder on startup/resume/clear/compact)\n");}/* Codex CLI */@@ -2767,8 +2824,9 @@ int cbm_cmd_uninstall(int argc, char **argv) {snprintf(settings_path, sizeof(settings_path), "%s/.claude/settings.json", home);if (!dry_run) {cbm_remove_claude_hooks(settings_path);+ cbm_remove_session_hooks(settings_path);}- printf(" removed PreToolUse hook\n");+ printf(" removed PreToolUse + SessionStart hooks\n");}if (agents.codex) {@@ -3039,9 +3097,7 @@ int cbm_cmd_update(int argc, char **argv) {}want_ui = (choice[0] == '2');}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *variant = want_ui ? "ui-" : "";- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *variant_label = want_ui ? "ui" : "standard";/* Step 3: Build download URL (CBM_DOWNLOAD_URL overrides for testing) */@@ -3049,7 +3105,6 @@ int cbm_cmd_update(int argc, char **argv) {const char *arch = detect_arch();const char *ext = strcmp(os, "windows") == 0 ? "zip" : "tar.gz";- // NOLINTNEXTLINE(concurrency-mt-unsafe)const char *base_url = getenv("CBM_DOWNLOAD_URL");if (!base_url || !base_url[0]) {base_url = "https://github.com/DeusData/codebase-memory-mcp/releases/latest/download";diff --git a/src/cypher/cypher.c b/src/cypher/cypher.cindex 64985cbcb..7a6137565 100644--- a/src/cypher/cypher.c+++ b/src/cypher/cypher.c@@ -15,7 +15,6 @@#include <stdio.h>#include <stdlib.h>#include <string.h>-// NOLINTNEXTLINE(misc-include-cleaner) — strings.h included for interface contract#include <strings.h> // strcasecmp/* ── Helpers ────────────────────────────────────────────────────── */@@ -148,7 +147,6 @@ static const kw_entry_t keywords[] = {static cbm_token_type_t keyword_lookup(const char *word) {/* Case-insensitive compare */for (const kw_entry_t *kw = keywords; kw->name; kw++) {- // NOLINTNEXTLINE(misc-include-cleaner) — strcasecmp provided by standard headerif (strcasecmp(word, kw->name) == 0) {return kw->type;}@@ -525,12 +523,10 @@ static int parse_rel(parser_t *p, cbm_rel_pattern_t *out) {if (match(p, TOK_COLON)) {int cap = 4;int n = 0;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **types = malloc(cap * sizeof(const char *));const cbm_token_t *t = expect(p, TOK_IDENT);if (!t) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(types);return -1;}@@ -542,13 +538,11 @@ static int parse_rel(parser_t *p, cbm_rel_pattern_t *out) {for (int i = 0; i < n; i++) {free((void *)types[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(types);return -1;}if (n >= cap) {cap *= 2;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)types = safe_realloc(types, cap * sizeof(const char *));}types[n++] = heap_strdup(t->text);@@ -628,7 +622,6 @@ static void expr_free(cbm_expr_t *e) {for (int i = 0; i < e->cond.in_value_count; i++) {free((void *)e->cond.in_values[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(e->cond.in_values);}expr_free(e->left);@@ -747,7 +740,6 @@ static cbm_expr_t *parse_condition_expr(parser_t *p) {}int vcap = 8;int vn = 0;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **vals = malloc(vcap * sizeof(const char *));while (!check(p, TOK_RBRACKET) && !check(p, TOK_EOF)) {if (vn > 0) {@@ -756,7 +748,6 @@ static cbm_expr_t *parse_condition_expr(parser_t *p) {if (check(p, TOK_STRING) || check(p, TOK_NUMBER)) {if (vn >= vcap) {vcap *= 2;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)vals = safe_realloc(vals, vcap * sizeof(const char *));}vals[vn++] = heap_strdup(advance(p)->text);@@ -1436,7 +1427,6 @@ static void free_pattern(cbm_pattern_t *pat) {for (int j = 0; j < r->type_count; j++) {free((void *)r->types[j]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(r->types);free((void *)r->direction);}@@ -1456,7 +1446,6 @@ static void free_where(cbm_where_clause_t *w) {for (int j = 0; j < w->conditions[i].in_value_count; j++) {free((void *)w->conditions[i].in_values[j]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(w->conditions[i].in_values);}free(w->conditions);@@ -1790,12 +1779,10 @@ static bool eval_condition(const cbm_condition_t *c, binding_t *b) {/* IS NULL / IS NOT NULL */if (strcmp(c->op, "IS NULL") == 0) {result = ((!actual || actual[0] == '\0') != 0);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (int)(c->negated ? !result : result);}if (strcmp(c->op, "IS NOT NULL") == 0) {result = ((actual && actual[0] != '\0') != 0);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (int)(c->negated ? !result : result);}@@ -1808,7 +1795,6 @@ static bool eval_condition(const cbm_condition_t *c, binding_t *b) {break;}}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (int)(c->negated ? !result : result);}@@ -1851,7 +1837,6 @@ static bool eval_condition(const cbm_condition_t *c, binding_t *b) {result = false;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (int)(c->negated ? !result : result);}@@ -1925,12 +1910,10 @@ typedef struct {static void rb_init(result_builder_t *rb) {memset(rb, 0, sizeof(*rb));rb->row_cap = 32;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)rb->rows = malloc(rb->row_cap * sizeof(const char **));}static void rb_set_columns(result_builder_t *rb, const char **cols, int count) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion,rb->columns = malloc(count * sizeof(const char *));for (int i = 0; i < count; i++) {rb->columns[i] = heap_strdup(cols[i]);@@ -1941,10 +1924,8 @@ static void rb_set_columns(result_builder_t *rb, const char **cols, int count) {static void rb_add_row(result_builder_t *rb, const char **values) {if (rb->row_count >= rb->row_cap) {rb->row_cap *= 2;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)rb->rows = safe_realloc(rb->rows, rb->row_cap * sizeof(const char **));}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **row = malloc(rb->col_count * sizeof(const char *));for (int i = 0; i < rb->col_count; i++) {row[i] = heap_strdup(values[i]);@@ -1954,7 +1935,6 @@ static void rb_add_row(result_builder_t *rb, const char **values) {/* ── Main execution ─────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters,readability-function-cognitive-complexity,readability-function-size)/* Hard ceiling: queries returning more than this trigger an error instead of data.* Prevents accidental multi-GB JSON payloads from unbounded MATCH (n) RETURN n. */#define CYPHER_RESULT_CEILING 100000@@ -2079,7 +2059,6 @@ static void expand_pattern_rels(cbm_store_t *store, cbm_pattern_t *pat, binding_cbm_node_pattern_t *target_node = &pat->nodes[ri + 1];const char *to_var = target_node->variable ? target_node->variable : "_n_t";- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool is_variable_length = (rel->min_hops != 1 || rel->max_hops != 1);binding_t *new_bindings = malloc(((*bind_cap * 10) + 1) * sizeof(binding_t));@@ -2120,9 +2099,7 @@ static void expand_pattern_rels(cbm_store_t *store, cbm_pattern_t *pat, binding_}cbm_store_traverse_free(&tr);} else {- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool is_inbound = rel->direction && strcmp(rel->direction, "inbound") == 0;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool is_any = rel->direction && strcmp(rel->direction, "any") == 0;const char *rel_var = rel->variable;@@ -2241,7 +2218,6 @@ static void rb_apply_order_by(result_builder_t *rb, const cbm_return_clause_t *rreturn;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool desc = ret->order_dir && strcmp(ret->order_dir, "DESC") == 0;bool numeric = false;for (int i = 0; i < rb->row_count; i++) {@@ -2267,7 +2243,6 @@ static void rb_apply_order_by(result_builder_t *rb, const cbm_return_clause_t *r} else {cmp = strcmp(rb->rows[j][order_col], rb->rows[j + 1][order_col]);}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)if (desc ? cmp < 0 : cmp > 0) {const char **tmp = rb->rows[j];rb->rows[j] = rb->rows[j + 1];@@ -2284,7 +2259,6 @@ static void rb_apply_skip_limit(result_builder_t *rb, int skip_n, int limit) {for (int c = 0; c < rb->col_count; c++) {free((void *)rb->rows[i][c]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(rb->rows[i]);}memmove(rb->rows, rb->rows + skip_n, (rb->row_count - skip_n) * sizeof(const char **));@@ -2294,7 +2268,6 @@ static void rb_apply_skip_limit(result_builder_t *rb, int skip_n, int limit) {for (int c = 0; c < rb->col_count; c++) {free((void *)rb->rows[i][c]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(rb->rows[i]);}rb->row_count = 0;@@ -2305,7 +2278,6 @@ static void rb_apply_skip_limit(result_builder_t *rb, int skip_n, int limit) {for (int c = 0; c < rb->col_count; c++) {free((void *)rb->rows[i][c]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(rb->rows[i]);}rb->row_count = limit;@@ -2339,7 +2311,6 @@ static void rb_apply_distinct(result_builder_t *rb) {for (int c = 0; c < rb->col_count; c++) {free((void *)rb->rows[i][c]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(rb->rows[i]);}}@@ -2351,15 +2322,12 @@ static void rb_free(result_builder_t *rb) {for (int c = 0; c < rb->col_count; c++) {free((void *)rb->rows[i][c]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(rb->rows[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(rb->rows);for (int i = 0; i < rb->col_count; i++) {free((void *)rb->columns[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(rb->columns);}@@ -2676,7 +2644,6 @@ static int execute_single(cbm_store_t *store, cbm_query_t *q, const char *projecfor (int ci = 0; ci < wc->count; ci++) {free((void *)aggs[a].group_vals[ci]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(aggs[a].group_vals);free(aggs[a].sums);free(aggs[a].counts);@@ -2941,7 +2908,6 @@ static int execute_single(cbm_store_t *store, cbm_query_t *q, const char *projec}found = agg_count++;snprintf(aggs[found].group_key, sizeof(aggs[found].group_key), "%s", key);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)aggs[found].group_vals = malloc(ret->count * sizeof(const char *));aggs[found].sums = calloc(ret->count, sizeof(double));aggs[found].counts = calloc(ret->count, sizeof(int));@@ -3038,7 +3004,6 @@ static int execute_single(cbm_store_t *store, cbm_query_t *q, const char *projec}free(aggs[a].collect_lists[ci]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(aggs[a].group_vals);free(aggs[a].sums);free(aggs[a].counts);@@ -3121,7 +3086,6 @@ static int execute_single(cbm_store_t *store, cbm_query_t *q, const char *projec/* ── Main entry point ─────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters,readability-function-cognitive-complexity,readability-function-size)int cbm_cypher_execute(cbm_store_t *store, const char *query, const char *project, int max_rows,cbm_cypher_result_t *out) {memset(out, 0, sizeof(*out));@@ -3192,16 +3156,13 @@ void cbm_cypher_result_free(cbm_cypher_result_t *r) {for (int i = 0; i < r->col_count; i++) {free((void *)r->columns[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(r->columns);for (int i = 0; i < r->row_count; i++) {for (int j = 0; j < r->col_count; j++) {free((void *)r->rows[i][j]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(r->rows[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(r->rows);free(r->error);memset(r, 0, sizeof(*r));diff --git a/src/discover/discover.c b/src/discover/discover.cindex a3aa007bc..8cfcd34a0 100644--- a/src/discover/discover.c+++ b/src/discover/discover.c@@ -205,7 +205,6 @@ typedef struct {int capacity;} file_list_t;-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void fl_add(file_list_t *fl, const char *abs_path, const char *rel_path, CBMLanguage lang,int64_t size) {if (fl->count >= fl->capacity) {@@ -219,7 +218,6 @@ static void fl_add(file_list_t *fl, const char *abs_path, const char *rel_path,}cbm_file_info_t *fi = &fl->files[fl->count++];- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerfi->path = strdup(abs_path);fi->rel_path = strdup(rel_path);fi->language = lang;@@ -228,7 +226,6 @@ static void fl_add(file_list_t *fl, const char *abs_path, const char *rel_path,/* ── Recursive walk ──────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters,misc-no-recursion)static void walk_dir(const char *dir_path, const char *rel_prefix, const cbm_discover_opts_t *opts,const cbm_gitignore_t *gitignore, const cbm_gitignore_t *cbmignore,file_list_t *out) {diff --git a/src/discover/gitignore.c b/src/discover/gitignore.cindex 8414d3447..76794449a 100644--- a/src/discover/gitignore.c+++ b/src/discover/gitignore.c@@ -39,7 +39,6 @@ struct cbm_gitignore {* Match a glob pattern against a string.* Handles: * (non-slash), ** (any path), ? (single non-slash), [class]*/-// NOLINTNEXTLINE(misc-no-recursion) — intentional recursive glob pattern matchingstatic bool glob_match(const char *pat, const char *str) {while (*pat && *str) {if (pat[0] == '*' && pat[1] == '*') {@@ -130,7 +129,6 @@ static bool glob_match(const char *pat, const char *str) {pat++;}if (negate_class) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion)matched = !matched;}if (!matched) {@@ -153,7 +151,6 @@ static bool glob_match(const char *pat, const char *str) {pat++;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return *pat == '\0' && *str == '\0';}@@ -219,7 +216,6 @@ static void gi_add_pattern(cbm_gitignore_t *gi, const char *line, int len) {return;}memcpy(p.pattern, start, len);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)p.pattern[len] = '\0';/* Grow array if needed */@@ -296,7 +292,6 @@ cbm_gitignore_t *cbm_gitignore_load(const char *path) {}size_t n = fread(buf, 1, size, f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[n] = '\0';(void)fclose(f);@@ -355,7 +350,6 @@ bool cbm_gitignore_matches(const cbm_gitignore_t *gi, const char *rel_path, bool}if (this_match) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion)matched = !p->negated;}}diff --git a/src/foundation/compat_fs.c b/src/foundation/compat_fs.cindex 65a4417d9..cd2073c01 100644--- a/src/foundation/compat_fs.c+++ b/src/foundation/compat_fs.c@@ -231,7 +231,6 @@ bool cbm_mkdir_p(const char *path, int mode) {return true;}/* Walk path and create each component */- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerchar *tmp = strdup(path);if (!tmp) {return false;diff --git a/src/foundation/diagnostics.c b/src/foundation/diagnostics.cindex ff6abac17..4b6254290 100644--- a/src/foundation/diagnostics.c+++ b/src/foundation/diagnostics.c@@ -161,7 +161,6 @@ static void *diag_thread_fn(void *arg) {/* ── Public API ──────────────────────────────────────────────────── */bool cbm_diag_start(void) {- // NOLINTNEXTLINE(concurrency-mt-unsafe)const char *env = getenv("CBM_DIAGNOSTICS");if (!env || (strcmp(env, "1") != 0 && strcmp(env, "true") != 0)) {return false;diff --git a/src/foundation/log.c b/src/foundation/log.cindex 35b673e1e..e0b989334 100644--- a/src/foundation/log.c+++ b/src/foundation/log.c@@ -65,7 +65,6 @@ void cbm_log(CBMLogLevel level, const char *msg, ...) {va_end(args);/* Write to stderr */- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)(void)fprintf(stderr, "%s\n", line_buf);/* Send to sink if registered */@@ -80,11 +79,9 @@ void cbm_log_int(CBMLogLevel level, const char *msg, const char *key, int64_t va}char line_buf[256];- // NOLINTNEXTLINE(misc-include-cleaner)snprintf(line_buf, sizeof(line_buf), "level=%s msg=%s %s=%" PRId64, level_str(level),msg ? msg : "", key ? key : "?", value);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)(void)fprintf(stderr, "%s\n", line_buf);if (g_log_sink) {diff --git a/src/foundation/mem.c b/src/foundation/mem.cindex fc32a89e3..2c6cc5c33 100644--- a/src/foundation/mem.c+++ b/src/foundation/mem.c@@ -58,7 +58,6 @@ static size_t os_rss(void) {}unsigned long pages = 0;unsigned long rss_pages = 0;- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)if (fscanf(f, "%lu %lu", &pages, &rss_pages) != 2) {rss_pages = 0;}@@ -83,11 +82,8 @@ static void check_pressure(size_t rss) {char rss_mb[32];char budget_mb[32];char pct_str[16];- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(rss_mb, sizeof(rss_mb), "%zu", rss / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(budget_mb, sizeof(budget_mb), "%zu", g_budget / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(pct_str, sizeof(pct_str), "%zu", g_budget > 0 ? (rss * 100) / g_budget : 0);cbm_log_warn("mem.pressure.warn", "rss_mb", rss_mb, "budget_mb", budget_mb, "pct", pct_str);} else if (!over && was) {@@ -95,11 +91,8 @@ static void check_pressure(size_t rss) {char rss_mb[32];char budget_mb[32];char pct_str[16];- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(rss_mb, sizeof(rss_mb), "%zu", rss / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(budget_mb, sizeof(budget_mb), "%zu", g_budget / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(pct_str, sizeof(pct_str), "%zu", g_budget > 0 ? (rss * 100) / g_budget : 0);cbm_log_info("mem.pressure.ok", "rss_mb", rss_mb, "budget_mb", budget_mb, "pct", pct_str);}@@ -125,9 +118,7 @@ void cbm_mem_init(double ram_fraction) {char budget_mb[32];char ram_mb[32];- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(budget_mb, sizeof(budget_mb), "%zu", g_budget / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(ram_mb, sizeof(ram_mb), "%zu", info.total_ram / MB_DIVISOR);cbm_log_info("mem.init", "budget_mb", budget_mb, "total_ram_mb", ram_mb);}diff --git a/src/foundation/platform.c b/src/foundation/platform.cindex fab2d3e74..62e1f0efd 100644--- a/src/foundation/platform.c+++ b/src/foundation/platform.c@@ -133,7 +133,6 @@ void *cbm_mmap_read(const char *path, size_t *out_size) {}*out_size = 0;- // NOLINTNEXTLINE(misc-include-cleaner) — open provided by standard headerint fd = open(path, O_RDONLY);if (fd < 0) {return NULL;@@ -214,7 +213,6 @@ bool cbm_file_exists(const char *path) {bool cbm_is_dir(const char *path) {struct stat st;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return stat(path, &st) == 0 && S_ISDIR(st.st_mode);}@@ -245,14 +243,12 @@ char *cbm_normalize_path_sep(char *path) {const char *cbm_get_home_dir(void) {static char buf[1024];- // NOLINTNEXTLINE(concurrency-mt-unsafe)const char *h = getenv("HOME");if (h && h[0]) {snprintf(buf, sizeof(buf), "%s", h);cbm_normalize_path_sep(buf);return buf;}- // NOLINTNEXTLINE(concurrency-mt-unsafe)h = getenv("USERPROFILE");if (h && h[0]) {snprintf(buf, sizeof(buf), "%s", h);diff --git a/src/foundation/vmem.c b/src/foundation/vmem.cindex e71f01ed5..df3b02694 100644--- a/src/foundation/vmem.c+++ b/src/foundation/vmem.c@@ -72,11 +72,8 @@ static void check_pressure(size_t allocated) {char alloc_mb[32];char budget_mb[32];char pct_str[16];- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(alloc_mb, sizeof(alloc_mb), "%zu", allocated / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(budget_mb, sizeof(budget_mb), "%zu", g_budget / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(pct_str, sizeof(pct_str), "%zu",g_budget > 0 ? (allocated * 100) / g_budget : 0);cbm_log_warn("mem.pressure.warn", "allocated_mb", alloc_mb, "budget_mb", budget_mb, "pct",@@ -87,11 +84,8 @@ static void check_pressure(size_t allocated) {char alloc_mb[32];char budget_mb[32];char pct_str[16];- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(alloc_mb, sizeof(alloc_mb), "%zu", allocated / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(budget_mb, sizeof(budget_mb), "%zu", g_budget / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(pct_str, sizeof(pct_str), "%zu",g_budget > 0 ? (allocated * 100) / g_budget : 0);cbm_log_info("mem.pressure.ok", "allocated_mb", alloc_mb, "budget_mb", budget_mb, "pct",@@ -128,9 +122,7 @@ void cbm_vmem_init(double ram_fraction) {char budget_mb[32];char ram_mb[32];- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(budget_mb, sizeof(budget_mb), "%zu", g_budget / MB_DIVISOR);- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)snprintf(ram_mb, sizeof(ram_mb), "%zu", info.total_ram / MB_DIVISOR);cbm_log_info("vmem.init", "budget_mb", budget_mb, "total_ram_mb", ram_mb);}diff --git a/src/foundation/yaml.c b/src/foundation/yaml.cindex f6ba4de58..f5b1ef783 100644--- a/src/foundation/yaml.c+++ b/src/foundation/yaml.c@@ -16,8 +16,7 @@#include <stddef.h> // NULL#include <stdio.h>#include <stdlib.h>-#include <string.h> // strdup-// NOLINTNEXTLINE(misc-include-cleaner) — strings.h included for interface contract+#include <string.h> // strdup#include <strings.h> // strcasecmp/* ── Node types ───────────────────────────────────────────────── */@@ -55,7 +54,6 @@ static void node_add_child(cbm_yaml_node_t *parent, cbm_yaml_node_t *child) {}if (parent->child_count >= parent->child_cap) {int new_cap = parent->child_cap < 8 ? 8 : parent->child_cap * 2;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_yaml_node_t **new_arr = realloc(parent->children, (size_t)new_cap * sizeof(*new_arr));if (!new_arr) {return;@@ -66,7 +64,6 @@ static void node_add_child(cbm_yaml_node_t *parent, cbm_yaml_node_t *child) {parent->children[parent->child_count++] = child;}-// NOLINTNEXTLINE(misc-no-recursion) — intentional recursive tree deallocationvoid cbm_yaml_free(cbm_yaml_node_t *root) {if (!root) {return;@@ -74,7 +71,6 @@ void cbm_yaml_free(cbm_yaml_node_t *root) {for (int i = 0; i < root->child_count; i++) {cbm_yaml_free(root->children[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(root->children);free(root->key);free(root->value);@@ -92,7 +88,6 @@ static char *trim_dup(const char *start, const char *end) {start++;}if (start >= end) {- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerreturn strdup("");}size_t len = (size_t)(end - start);@@ -195,7 +190,6 @@ cbm_yaml_node_t *cbm_yaml_parse(const char *text, int len) {node_add_child(list_parent, item);}- // NOLINTNEXTLINE(clang-analyzer-unix.Malloc)p = (eol < end) ? eol + 1 : end;continue;}@@ -271,7 +265,6 @@ cbm_yaml_node_t *cbm_yaml_parse(const char *text, int len) {break;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)cbm_yaml_node_t *child = node_new(is_list ? YAML_LIST : YAML_MAP);if (child) {child->key = key;@@ -285,11 +278,9 @@ cbm_yaml_node_t *cbm_yaml_parse(const char *text, int len) {}}- // NOLINTNEXTLINE(clang-analyzer-unix.Malloc)p = (eol < end) ? eol + 1 : end;}- // NOLINTNEXTLINE(clang-analyzer-unix.Malloc)return root;}@@ -374,7 +365,6 @@ bool cbm_yaml_get_bool(const cbm_yaml_node_t *root, const char *path, bool defaureturn default_val;}- // NOLINTNEXTLINE(misc-include-cleaner) — strcasecmp provided by standard headerif (strcasecmp(str, "true") == 0 || strcasecmp(str, "yes") == 0 || strcasecmp(str, "on") == 0 ||strcmp(str, "1") == 0) {return true;diff --git a/src/graph_buffer/graph_buffer.c b/src/graph_buffer/graph_buffer.cindex bf48b426d..b79110a57 100644--- a/src/graph_buffer/graph_buffer.c+++ b/src/graph_buffer/graph_buffer.c@@ -70,7 +70,6 @@ struct cbm_gbuf {/* ── Helpers ─────────────────────────────────────────────────────── */static char *heap_strdup(const char *s) {- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerreturn s ? strdup(s) : strdup("{}");}@@ -107,12 +106,10 @@ static edge_ptr_array_t *get_or_create_edge_array(CBMHashTable *ht, const char *}/* Free a node_ptr_array_t (callback for hash table iteration) */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_node_array(const char *key, void *value, void *ud) {(void)ud;node_ptr_array_t *arr = value;if (arr) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_free(arr);free(arr);}@@ -120,12 +117,10 @@ static void free_node_array(const char *key, void *value, void *ud) {}/* Free an edge_ptr_array_t (callback) */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_edge_array(const char *key, void *value, void *ud) {(void)ud;edge_ptr_array_t *arr = value;if (arr) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_free(arr);free(arr);}@@ -133,7 +128,6 @@ static void free_edge_array(const char *key, void *value, void *ud) {}/* Free keys only (for node_by_id, edge_by_key) */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_key_only(const char *key, void *value, void *ud) {(void)value;(void)ud;@@ -157,7 +151,6 @@ static void free_edge_strings(cbm_gbuf_edge_t *e) {/* ── Lifecycle ──────────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)cbm_gbuf_t *cbm_gbuf_new(const char *project, const char *root_path) {cbm_gbuf_t *gb = calloc(1, sizeof(cbm_gbuf_t));if (!gb) {@@ -202,7 +195,6 @@ void cbm_gbuf_free(cbm_gbuf_t *gb) {free_node_strings(n);free(n);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_free(&gb->nodes);/* Free each individually-allocated edge */@@ -211,7 +203,6 @@ void cbm_gbuf_free(cbm_gbuf_t *gb) {free_edge_strings(e);free(e);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_free(&gb->edges);/* Free hash tables — may be NULL if already released by dump_to_sqlite */@@ -274,7 +265,6 @@ void cbm_gbuf_set_next_id(cbm_gbuf_t *gb, int64_t next_id) {/* ── Node operations ─────────────────────────────────────────────── */int64_t cbm_gbuf_upsert_node(cbm_gbuf_t *gb, const char *label, const char *name,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)const char *qualified_name, const char *file_path, int start_line,int end_line, const char *properties_json) {if (!gb || !qualified_name) {@@ -328,7 +318,6 @@ int64_t cbm_gbuf_upsert_node(cbm_gbuf_t *gb, const char *label, const char *namenode->properties_json = heap_strdup(properties_json);/* Store pointer in array */- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(&gb->nodes, node);/* Primary indexes — QN key is borrowed from the node's own string */@@ -347,11 +336,9 @@ int64_t cbm_gbuf_upsert_node(cbm_gbuf_t *gb, const char *label, const char *name/* Secondary indexes */node_ptr_array_t *by_label = get_or_create_node_array(gb->nodes_by_label, label ? label : "");- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(by_label, (const cbm_gbuf_node_t *)node);node_ptr_array_t *by_name = get_or_create_node_array(gb->nodes_by_name, name ? name : "");- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(by_name, (const cbm_gbuf_node_t *)node);return id;@@ -796,7 +783,6 @@ int64_t cbm_gbuf_insert_edge(cbm_gbuf_t *gb, int64_t source_id, int64_t target_iedge->properties_json = heap_strdup(properties_json);/* Store pointer in array */- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(&gb->edges, edge);/* Dedup index */@@ -805,16 +791,13 @@ int64_t cbm_gbuf_insert_edge(cbm_gbuf_t *gb, int64_t source_id, int64_t target_i/* Secondary indexes */make_src_type_key(key, sizeof(key), source_id, type);edge_ptr_array_t *st = get_or_create_edge_array(gb->edges_by_source_type, key);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(st, (const cbm_gbuf_edge_t *)edge);make_src_type_key(key, sizeof(key), target_id, type);edge_ptr_array_t *tt = get_or_create_edge_array(gb->edges_by_target_type, key);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(tt, (const cbm_gbuf_edge_t *)edge);edge_ptr_array_t *bt = get_or_create_edge_array(gb->edges_by_type, type);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(bt, (const cbm_gbuf_edge_t *)edge);return id;@@ -925,16 +908,13 @@ int cbm_gbuf_delete_edges_by_type(cbm_gbuf_t *gb, const char *type) {make_src_type_key(key, sizeof(key), e->source_id, e->type);edge_ptr_array_t *st = get_or_create_edge_array(gb->edges_by_source_type, key);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(st, (const cbm_gbuf_edge_t *)e);make_src_type_key(key, sizeof(key), e->target_id, e->type);edge_ptr_array_t *tt = get_or_create_edge_array(gb->edges_by_target_type, key);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(tt, (const cbm_gbuf_edge_t *)e);edge_ptr_array_t *bt = get_or_create_edge_array(gb->edges_by_type, e->type);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(bt, (const cbm_gbuf_edge_t *)e);}@@ -944,7 +924,6 @@ int cbm_gbuf_delete_edges_by_type(cbm_gbuf_t *gb, const char *type) {/* ── Merge ───────────────────────────────────────────────────────── *//* Free remap hash table entries (key = heap string, value = heap int64_t*) */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_remap_entry(const char *key, void *val, void *ud) {(void)ud;free((void *)key);@@ -1019,7 +998,6 @@ int cbm_gbuf_merge(cbm_gbuf_t *dst, cbm_gbuf_t *src) {node->properties_json = heap_strdup(sn->properties_json);/* Store in array */- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(&dst->nodes, node);/* Primary indexes */@@ -1036,12 +1014,10 @@ int cbm_gbuf_merge(cbm_gbuf_t *dst, cbm_gbuf_t *src) {/* Secondary indexes */node_ptr_array_t *by_label =get_or_create_node_array(dst->nodes_by_label, node->label ? node->label : "");- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(by_label, (const cbm_gbuf_node_t *)node);node_ptr_array_t *by_name =get_or_create_node_array(dst->nodes_by_name, node->name ? node->name : "");- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(by_name, (const cbm_gbuf_node_t *)node);/* Keep next_id above all inserted IDs */@@ -1101,7 +1077,6 @@ static char *extract_url_path(const char *props) {if (!end || end <= key) {return NULL;}- // NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard headerreturn cbm_strndup(key, (size_t)(end - key));}@@ -1170,7 +1145,6 @@ int cbm_gbuf_dump_to_sqlite(cbm_gbuf_t *gb, const char *path) {/* Build CBMDumpEdge array with remapped IDs */CBMDumpEdge *dump_edges =malloc((size_t)(valid_edges > 0 ? valid_edges : 1) * sizeof(CBMDumpEdge));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **url_paths = calloc((size_t)(valid_edges > 0 ? valid_edges : 1), sizeof(char *));int edge_idx = 0;@@ -1199,7 +1173,6 @@ int cbm_gbuf_dump_to_sqlite(cbm_gbuf_t *gb, const char *path) {/* Generate ISO 8601 timestamp */time_t now = time(NULL);- // NOLINTNEXTLINE(concurrency-mt-unsafe) — called once during single-threaded dumpstruct tm *tm_val = gmtime(&now);char indexed_at[64];strftime(indexed_at, sizeof(indexed_at), "%Y-%m-%dT%H:%M:%SZ", tm_val);@@ -1249,7 +1222,6 @@ int cbm_gbuf_dump_to_sqlite(cbm_gbuf_t *gb, const char *path) {for (int i = 0; i < edge_idx; i++) {free(url_paths[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(url_paths);free(dump_edges);free(dump_nodes);diff --git a/src/main.c b/src/main.cindex 800f9ab7f..28efdb7e7 100644--- a/src/main.c+++ b/src/main.c@@ -104,7 +104,6 @@ static int watcher_index_fn(const char *project_name, const char *root_path, voistatic int run_cli(int argc, char **argv) {if (argc < 1) {- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)(void)fprintf(stderr, "Usage: codebase-memory-mcp cli <tool_name> [json_args]\n");return 1;}@@ -114,7 +113,6 @@ static int run_cli(int argc, char **argv) {cbm_mcp_server_t *srv = cbm_mcp_server_new(NULL);if (!srv) {- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)(void)fprintf(stderr, "Failed to create server\n");return 1;}@@ -222,9 +220,7 @@ int main(int argc, char **argv) {signal(SIGTERM, signal_handler);signal(SIGINT, signal_handler);#else- // NOLINTNEXTLINE(misc-include-cleaner) — sigaction provided by standard headerstruct sigaction sa = {0};- // NOLINTNEXTLINE(misc-include-cleaner) — sa_handler provided by standard headersa.sa_handler = signal_handler;sigemptyset(&sa.sa_mask);sa.sa_flags = 0;diff --git a/src/mcp/mcp.c b/src/mcp/mcp.cindex f292da292..58e1b0526 100644--- a/src/mcp/mcp.c+++ b/src/mcp/mcp.c@@ -451,7 +451,6 @@ char *cbm_mcp_get_arguments(const char *params_json) {return result ? result : heap_strdup("{}");}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)char *cbm_mcp_get_string_arg(const char *args_json, const char *key) {yyjson_doc *doc = yyjson_read(args_json, strlen(args_json), 0);if (!doc) {@@ -467,7 +466,6 @@ char *cbm_mcp_get_string_arg(const char *args_json, const char *key) {return result;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_mcp_get_int_arg(const char *args_json, const char *key, int default_val) {yyjson_doc *doc = yyjson_read(args_json, strlen(args_json), 0);if (!doc) {@@ -483,7 +481,6 @@ int cbm_mcp_get_int_arg(const char *args_json, const char *key, int default_val)return result;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)bool cbm_mcp_get_bool_arg(const char *args_json, const char *key) {yyjson_doc *doc = yyjson_read(args_json, strlen(args_json), 0);if (!doc) {@@ -909,7 +906,6 @@ static char *handle_get_graph_schema(cbm_mcp_server_t *srv, const char *args) {char adr_path[4096];snprintf(adr_path, sizeof(adr_path), "%s/.codebase-memory/adr.md", proj_info.root_path);struct stat adr_st;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool adr_exists = (stat(adr_path, &adr_st) == 0);yyjson_mut_obj_add_bool(doc, root, "adr_present", adr_exists);if (!adr_exists) {@@ -1339,9 +1335,7 @@ static char *handle_trace_call_path(cbm_mcp_server_t *srv, const char *args) {/* Run BFS for each requested direction.* IMPORTANT: yyjson_mut_obj_add_str borrows pointers — we must keep* traversal results alive until after yy_doc_to_str serialization. */- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool do_outbound = strcmp(direction, "outbound") == 0 || strcmp(direction, "both") == 0;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool do_inbound = strcmp(direction, "inbound") == 0 || strcmp(direction, "both") == 0;cbm_traverse_result_t tr_out = {0};@@ -1553,7 +1547,6 @@ static char *handle_index_repository(cbm_mcp_server_t *srv, const char *args) {char adr_path[4096];snprintf(adr_path, sizeof(adr_path), "%s/.codebase-memory/adr.md", repo_path);struct stat adr_st;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool adr_exists = (stat(adr_path, &adr_st) == 0);yyjson_mut_obj_add_bool(doc, root, "adr_present", adr_exists);if (!adr_exists) {@@ -1786,9 +1779,7 @@ static char *build_snippet_response(cbm_mcp_server_t *srv, cbm_node_t *node,for (int i = 0; i < nb_callee_count; i++) {free(nb_callees[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(nb_callers);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(nb_callees);free(root_path);free(abs_path);@@ -1943,7 +1934,6 @@ static int search_result_cmp(const void *a, const void *b) {static void build_grep_cmd(char *cmd, size_t cmd_sz, bool use_regex, bool scoped,const char *file_pattern, const char *tmpfile, const char *filelist,const char *root_path) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *flag = use_regex ? "-E" : "-F";if (scoped) {if (file_pattern) {@@ -2225,7 +2215,6 @@ static char *handle_search_code(cbm_mcp_server_t *srv, const char *args) {free(file_pattern);return cbm_mcp_text_result("search failed: temp file", true);}- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)(void)fprintf(tf, "%s\n", pattern);(void)fclose(tf);@@ -2268,7 +2257,6 @@ static char *handle_search_code(cbm_mcp_server_t *srv, const char *args) {char cmd[4096];build_grep_cmd(cmd, sizeof(cmd), use_regex, scoped, file_pattern, tmpfile, filelist, root_path);- // NOLINTNEXTLINE(bugprone-command-processor,cert-env33-c)FILE *fp = cbm_popen(cmd, "r");if (!fp) {cbm_unlink(tmpfile);@@ -2537,7 +2525,6 @@ static char *handle_detect_changes(cbm_mcp_server_t *srv, const char *args) {root_path, base_branch, root_path);#endif- // NOLINTNEXTLINE(bugprone-command-processor,cert-env33-c)FILE *fp = cbm_popen(cmd, "r");if (!fp) {free(root_path);@@ -2740,7 +2727,6 @@ static char *handle_ingest_traces(cbm_mcp_server_t *srv, const char *args) {/* ── Tool dispatch ────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)char *cbm_mcp_handle_tool(cbm_mcp_server_t *srv, const char *tool_name, const char *args_json) {if (!tool_name) {return cbm_mcp_text_result("missing tool name", true);@@ -2908,7 +2894,6 @@ static void maybe_auto_index(cbm_mcp_server_t *srv) {}char cmd[1024];snprintf(cmd, sizeof(cmd), "git -C '%s' ls-files 2>/dev/null | wc -l", srv->session_root);- // NOLINTNEXTLINE(bugprone-command-processor,cert-env33-c)FILE *fp = cbm_popen(cmd, "r");if (fp) {char line[64];@@ -3072,7 +3057,6 @@ char *cbm_mcp_server_handle(cbm_mcp_server_t *srv, const char *line) {cbm_clock_gettime(CLOCK_MONOTONIC, &t1);long long dur_us = ((long long)(t1.tv_sec - t0.tv_sec) * 1000000LL) +((long long)(t1.tv_nsec - t0.tv_nsec) / 1000LL);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool is_err = (result_json != NULL) && (strstr(result_json, "\"isError\":true") != NULL);cbm_diag_record_query(dur_us, is_err);@@ -3097,7 +3081,6 @@ char *cbm_mcp_server_handle(cbm_mcp_server_t *srv, const char *line) {/* ── Event loop ───────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_mcp_server_run(cbm_mcp_server_t *srv, FILE *in, FILE *out) {char *line = NULL;size_t cap = 0;@@ -3251,7 +3234,6 @@ int cbm_mcp_server_run(cbm_mcp_server_t *srv, FILE *in, FILE *out) {char *resp = cbm_mcp_server_handle(srv, line);if (resp) {- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)(void)fprintf(out, "%s\n", resp);(void)fflush(out);free(resp);diff --git a/src/pipeline/fqn.c b/src/pipeline/fqn.cindex 0936c78c0..66bdd9bd4 100644--- a/src/pipeline/fqn.c+++ b/src/pipeline/fqn.c@@ -21,7 +21,6 @@/* Build a dot-joined string from segments. Returns heap-allocated string. */static char *join_segments(const char **segments, int count) {if (count == 0) {- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerreturn strdup("");}size_t total = 0;@@ -50,7 +49,6 @@ static char *join_segments(const char **segments, int count) {/* ── Public API ──────────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)char *cbm_pipeline_fqn_compute(const char *project, const char *rel_path, const char *name) {if (!project) {return strdup("");@@ -125,7 +123,6 @@ char *cbm_pipeline_fqn_module(const char *project, const char *rel_path) {return cbm_pipeline_fqn_compute(project, rel_path, NULL);}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)char *cbm_pipeline_fqn_folder(const char *project, const char *rel_dir) {if (!project) {return strdup("");diff --git a/src/pipeline/httplink.c b/src/pipeline/httplink.cindex 7d72c1c5e..dee017d03 100644--- a/src/pipeline/httplink.c+++ b/src/pipeline/httplink.c@@ -102,7 +102,6 @@ double cbm_normalized_levenshtein(const char *a, const char *b) {return 1.0 - ((double)dist / (double)max_len);}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_ht_key(const char *key, void *val, void *ud) {(void)val;(void)ud;@@ -127,7 +126,6 @@ double cbm_ngram_overlap(const char *a, const char *b, int n) {memcpy(key, a + i, (size_t)klen);key[klen] = '\0';if (!cbm_ht_get(set_a, key)) {- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by string.hcbm_ht_set(set_a, strdup(key), (void *)1);}}@@ -141,7 +139,6 @@ double cbm_ngram_overlap(const char *a, const char *b, int n) {memcpy(key, b + i, (size_t)klen);key[klen] = '\0';if (!cbm_ht_get(set_b, key)) {- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by string.hcbm_ht_set(set_b, strdup(key), (void *)1);if (cbm_ht_get(set_a, key)) {intersection++;@@ -296,21 +293,17 @@ bool cbm_paths_match(const char *call_path, const char *route_path) {int nc = 0;int nr = 0;- // NOLINTNEXTLINE(concurrency-mt-unsafe)char *tok = strtok(call_copy, "/");while (tok && nc < 64) {call_segs[nc++] = tok;- // NOLINTNEXTLINE(concurrency-mt-unsafe)tok = strtok(NULL, "/");}/* Need to re-copy route since strtok consumed call_copy's context */normalize_to_buf(route_path, route_copy, sizeof(route_copy));- // NOLINTNEXTLINE(concurrency-mt-unsafe)tok = strtok(route_copy, "/");while (tok && nr < 64) {route_segs[nr++] = tok;- // NOLINTNEXTLINE(concurrency-mt-unsafe)tok = strtok(NULL, "/");}@@ -377,19 +370,15 @@ static double segment_jaccard(const char *norm_call, const char *norm_route) {int na = 0;int nb = 0;- // NOLINTNEXTLINE(concurrency-mt-unsafe)char *t = strtok(a, "/");while (t && na < 64) {a_segs[na++] = t;- // NOLINTNEXTLINE(concurrency-mt-unsafe)t = strtok(NULL, "/");}- // NOLINTNEXTLINE(concurrency-mt-unsafe)t = strtok(b, "/");while (t && nb < 64) {b_segs[nb++] = t;- // NOLINTNEXTLINE(concurrency-mt-unsafe)t = strtok(NULL, "/");}@@ -451,18 +440,14 @@ double cbm_path_match_score(const char *call_path, const char *route_path) {char *rs[64];int nc2 = 0;int nr2 = 0;- // NOLINTNEXTLINE(concurrency-mt-unsafe)char *tk = strtok(c2, "/");while (tk && nc2 < 64) {cs[nc2++] = tk;- // NOLINTNEXTLINE(concurrency-mt-unsafe)tk = strtok(NULL, "/");}- // NOLINTNEXTLINE(concurrency-mt-unsafe)tk = strtok(r2, "/");while (tk && nr2 < 64) {rs[nr2++] = tk;- // NOLINTNEXTLINE(concurrency-mt-unsafe)tk = strtok(NULL, "/");}@@ -488,7 +473,6 @@ double cbm_path_match_score(const char *call_path, const char *route_path) {/* Compute confidence: 0.5 × jaccard + 0.5 × depthFactor */double jaccard = segment_jaccard(norm_call, norm_route);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)int depth = count_segments(is_suffix ? norm_route : norm_call);double depth_factor = (double)depth / DEPTH_DIVISOR;if (depth_factor > 1.0) {@@ -514,19 +498,15 @@ bool cbm_same_service(const char *qn1, const char *qn2) {int na = 0;int nb = 0;- // NOLINTNEXTLINE(concurrency-mt-unsafe)char *tok = strtok(a, ".");while (tok && na < 64) {a_segs[na++] = tok;- // NOLINTNEXTLINE(concurrency-mt-unsafe)tok = strtok(NULL, ".");}- // NOLINTNEXTLINE(concurrency-mt-unsafe)tok = strtok(b, ".");while (tok && nb < 64) {b_segs[nb++] = tok;- // NOLINTNEXTLINE(concurrency-mt-unsafe)tok = strtok(NULL, ".");}@@ -575,7 +555,6 @@ const char *cbm_detect_protocol(const char *source) {}/* containsTestSegment: check if path has a segment that equals testWord */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static bool contains_test_segment(const char *fp, const char *test_word) {char work[1024];int len = (int)strlen(fp);@@ -772,7 +751,6 @@ int cbm_extract_json_string_paths(const char *text, char **out, int max_out) {/* ── Route extraction: Python ──────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_extract_python_routes(const char *name, const char *qn, const char **decorators, int ndec,cbm_route_handler_t *out, int max_out) {if (!decorators || ndec <= 0) {@@ -854,7 +832,6 @@ int cbm_extract_python_routes(const char *name, const char *qn, const char **dec/* ── Route extraction: Go gin/chi ──────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_extract_go_routes(const char *name, const char *qn, const char *source,cbm_route_handler_t *out, int max_out) {if (!source || !*source) {@@ -1120,7 +1097,6 @@ int cbm_extract_go_routes(const char *name, const char *qn, const char *source,/* ── Route extraction: Java Spring ─────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_extract_java_routes(const char *name, const char *qn, const char **decorators, int ndec,cbm_route_handler_t *out, int max_out) {if (!decorators || ndec <= 0) {@@ -1215,7 +1191,6 @@ int cbm_extract_java_routes(const char *name, const char *qn, const char **decor/* ── Route extraction: Kotlin Ktor ─────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_extract_ktor_routes(const char *name, const char *qn, const char *source,cbm_route_handler_t *out, int max_out) {if (!source || !*source) {@@ -1264,7 +1239,6 @@ int cbm_extract_ktor_routes(const char *name, const char *qn, const char *sourcewhile (count < max_out && cbm_regexec(&ktor_re, p, 3, match, 0) == 0) {/* Make sure this isn't the webSocket match (check if preceded by "web") */const char *match_start = p + match[0].rm_so;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool is_ws = (match_start >= source + 3 && strncmp(match_start - 3, "web", 3) == 0);if (!is_ws) {@@ -1315,7 +1289,6 @@ static bool is_express_receiver(const char *receiver) {return false;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_extract_express_routes(const char *name, const char *qn, const char *source,cbm_route_handler_t *out, int max_out) {if (!source || !*source) {@@ -1381,7 +1354,6 @@ int cbm_extract_express_routes(const char *name, const char *qn, const char *sou/* ── Route extraction: Laravel ─────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_extract_laravel_routes(const char *name, const char *qn, const char *source,cbm_route_handler_t *out, int max_out) {if (!source || !*source) {@@ -1442,7 +1414,6 @@ int cbm_extract_laravel_routes(const char *name, const char *qn, const char *sou/* ── Read source lines ─────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)char *cbm_read_source_lines_disk(const char *root_dir, const char *rel_path, int start_line,int end_line) {char full_path[2048];@@ -1494,7 +1465,6 @@ char *cbm_read_source_lines_disk(const char *root_dir, const char *rel_path, int(void)fclose(f);if (result) {- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)result[result_len] = '\0';}return result;@@ -1502,7 +1472,6 @@ char *cbm_read_source_lines_disk(const char *root_dir, const char *rel_path, int/* ── Read source lines from cached buffer ──────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)char *cbm_read_source_lines_cached(const char *source, int source_len, int start_line,int end_line) {if (!source || source_len <= 0 || start_line <= 0 || end_line < start_line) {@@ -1558,7 +1527,6 @@ char *cbm_read_source_lines_cached(const char *source, int source_len, int start}if (result) {- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)result[result_len] = '\0';}return result;@@ -1635,7 +1603,6 @@ cbm_httplink_config_t cbm_httplink_load_config(const char *dir) {size_t nread = fread(buf, 1, (size_t)size, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';/* Parse YAML */@@ -1652,7 +1619,6 @@ cbm_httplink_config_t cbm_httplink_load_config(const char *dir) {/* Extract fuzzy_matching */if (cbm_yaml_has(root, "http_linker.fuzzy_matching")) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion)cfg.fuzzy_matching = cbm_yaml_get_bool(root, "http_linker.fuzzy_matching", true) ? 1 : 0;}@@ -1660,11 +1626,9 @@ cbm_httplink_config_t cbm_httplink_load_config(const char *dir) {const char *items[128];int count = cbm_yaml_get_str_list(root, "http_linker.exclude_paths", items, 128);if (count > 0) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cfg.exclude_paths = calloc((size_t)count, sizeof(char *));if (cfg.exclude_paths) {for (int i = 0; i < count; i++) {- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headercfg.exclude_paths[i] = strdup(items[i]);}cfg.exclude_path_count = count;@@ -1682,7 +1646,6 @@ void cbm_httplink_config_free(cbm_httplink_config_t *cfg) {for (int i = 0; i < cfg->exclude_path_count; i++) {free(cfg->exclude_paths[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(cfg->exclude_paths);cfg->exclude_paths = NULL;cfg->exclude_path_count = 0;diff --git a/src/pipeline/pass_calls.c b/src/pipeline/pass_calls.cindex 9147df532..3acdf457e 100644--- a/src/pipeline/pass_calls.c+++ b/src/pipeline/pass_calls.c@@ -49,7 +49,6 @@ static char *read_file(const char *path, int *out_len) {size_t nread = fread(buf, 1, size, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';*out_len = (int)nread;return buf;@@ -68,7 +67,6 @@ static const char *itoa_log(int val) {/* Build per-file import map from cached extraction result or graph buffer edges.* Returns parallel arrays of (local_name, module_qn) pairs. Caller frees. */static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)const CBMFileResult *result, const char ***out_keys,const char ***out_vals, int *out_count) {*out_keys = NULL;@@ -77,9 +75,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,/* Fast path: build from cached extraction result (no JSON parsing) */if (result && result->imports.count > 0) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **keys = calloc((size_t)result->imports.count, sizeof(const char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **vals = calloc((size_t)result->imports.count, sizeof(const char *));int count = 0;@@ -94,7 +90,6 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,if (!target) {continue;}- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerkeys[count] = strdup(imp->local_name);vals[count] = target->qualified_name; /* borrowed from gbuf */count++;@@ -122,9 +117,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,return 0;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **keys = calloc(edge_count, sizeof(const char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **vals = calloc(edge_count, sizeof(const char *));int count = 0;@@ -141,7 +134,6 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,start += strlen("\"local_name\":\"");const char *end = strchr(start, '"');if (end && end > start) {- // NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard headerchar *key = cbm_strndup(start, end - start);keys[count] = key;vals[count] = target->qualified_name;@@ -169,7 +161,6 @@ static void free_import_map(const char **keys, const char **vals, int count) {}}-// NOLINTNEXTLINE(misc-include-cleaner) — cbm_file_info_t provided by standard headerint cbm_pipeline_pass_calls(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files, int file_count) {cbm_log_info("pass.start", "pass", "calls", "files", itoa_log(file_count));@@ -418,7 +409,6 @@ int cbm_pipeline_pass_calls(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *file* creates CALLS edges from the endpoint to the dependency function.* Without this, FastAPI auth/DI functions appear as dead code (in_degree=0). */-// NOLINTNEXTLINE(misc-include-cleaner) — cbm_file_info_t provided by standard headervoid cbm_pipeline_pass_fastapi_depends(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,int file_count) {cbm_regex_t depends_re;diff --git a/src/pipeline/pass_compile_commands.c b/src/pipeline/pass_compile_commands.cindex 3b952dab7..8a0ee26e6 100644--- a/src/pipeline/pass_compile_commands.c+++ b/src/pipeline/pass_compile_commands.c@@ -4,7 +4,6 @@* Parses compile_commands.json to extract per-file include paths, defines,* and C/C++ standard flags.*/-// NOLINTNEXTLINE(misc-include-cleaner) — pipeline.h included for interface contract#include "pipeline/pipeline.h"#include "pipeline/pipeline_internal.h"@@ -38,7 +37,6 @@ int cbm_split_command(const char *cmd, char **out, int max_out) {} else if (c == ' ' || c == '\t') {if (clen > 0 && count < max_out) {current[clen] = '\0';- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerout[count++] = strdup(current);clen = 0;}@@ -83,9 +81,7 @@ cbm_compile_flags_t *cbm_extract_flags(const char **args, int argc, const char *}/* Pre-allocate arrays */- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)f->include_paths = calloc(argc, sizeof(char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)f->defines = calloc(argc, sizeof(char *));for (int i = 0; i < argc; i++) {@@ -141,12 +137,10 @@ void cbm_compile_flags_free(cbm_compile_flags_t *f) {for (int i = 0; i < f->include_count; i++) {free(f->include_paths[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(f->include_paths);for (int i = 0; i < f->define_count; i++) {free(f->defines[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(f->defines);free(f);}@@ -176,9 +170,7 @@ int cbm_parse_compile_commands(const char *json_data, const char *repo_path, chareturn 0;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **paths = calloc(arr_len, sizeof(char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_compile_flags_t **flags = calloc(arr_len, sizeof(cbm_compile_flags_t *));int count = 0;diff --git a/src/pipeline/pass_configlink.c b/src/pipeline/pass_configlink.cindex e384725ab..979653c60 100644--- a/src/pipeline/pass_configlink.c+++ b/src/pipeline/pass_configlink.c@@ -51,7 +51,6 @@ static bool is_dep_section(const char *s) {static const char *secs[] = {"dependencies", "devdependencies", "peerdependencies","dev-dependencies", "build-dependencies", NULL};for (int i = 0; secs[i]; i++) {- // NOLINTNEXTLINE(misc-include-cleaner) — strcasestr provided by standard headerif (cbm_strcasestr(s, secs[i]) != NULL) {return true;}@@ -62,7 +61,6 @@ static bool is_dep_section(const char *s) {/* ── Strategy 1: Config Key → Code Symbol ───────────────────────── */typedef struct {- // NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard headerint64_t node_id;char normalized[256];char name[256];@@ -229,7 +227,6 @@ static int collect_manifest_deps(const cbm_gbuf_node_t *const *vars, int var_couchar qn_copy[512];snprintf(qn_copy, sizeof(qn_copy), "%s", vars[i]->qualified_name);char *saveptr = NULL;- // NOLINTNEXTLINE(misc-include-cleaner) — strtok_r provided by standard headerchar *part = strtok_r(qn_copy, ".", &saveptr);while (part) {char lower[128];@@ -354,7 +351,6 @@ static int strategy_dep_imports(cbm_gbuf_t *gb) {/* ── Strategy 3: Config File Path → Code String Reference ───────── *//* Disk-based fallback: reads source from disk (sequential pipeline path). */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int strategy_file_refs_disk(cbm_gbuf_t *gb, const char *project, const char *repo_path) {/* Collect config Module nodes */const cbm_gbuf_node_t **modules = NULL;@@ -438,7 +434,6 @@ static int strategy_file_refs_disk(cbm_gbuf_t *gb, const char *project, const chcontinue;}size_t nread = fread(source, 1, (size_t)fsize, f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)source[nread] = '\0';(void)fclose(f);diff --git a/src/pipeline/pass_configures.c b/src/pipeline/pass_configures.cindex 764bdfdc4..7579b89fd 100644--- a/src/pipeline/pass_configures.c+++ b/src/pipeline/pass_configures.c@@ -4,7 +4,6 @@* Pure helper functions for detecting environment variable names,* normalizing config keys, and identifying config file extensions.*/-// NOLINTNEXTLINE(misc-include-cleaner) — pipeline.h included for interface contract#include "pipeline/pipeline.h"#include "pipeline/pipeline_internal.h"@@ -64,7 +63,6 @@ int cbm_normalize_config_key(const char *key, char *norm_out, size_t norm_sz) {size_t out_pos = 0;char *saveptr = NULL;- // NOLINTNEXTLINE(misc-include-cleaner) — strtok_r provided by standard headerchar *part = strtok_r(buf, " ", &saveptr);while (part) {/* Split camelCase within this part */diff --git a/src/pipeline/pass_definitions.c b/src/pipeline/pass_definitions.cindex bfe1f80d0..ec51f09ed 100644--- a/src/pipeline/pass_definitions.c+++ b/src/pipeline/pass_definitions.c@@ -47,7 +47,6 @@ static char *read_file(const char *path, int *out_len) {size_t nread = fread(buf, 1, size, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';*out_len = (int)nread;return buf;@@ -66,7 +65,6 @@ static const char *itoa_log(int val) {/* Append a JSON-escaped string value to buf at position *pos.* Writes: ,"key":"escaped_value"* Handles: \, ", \n, \r, \t */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void append_json_string(char *buf, size_t bufsize, size_t *pos, const char *key,const char *val) {if (!val || !val[0]) {@@ -197,7 +195,6 @@ static void build_def_props(char *buf, size_t bufsize, const CBMDefinition *def)}}-// NOLINTNEXTLINE(misc-include-cleaner) — cbm_file_info_t provided by standard headerint cbm_pipeline_pass_definitions(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,int file_count) {cbm_log_info("pass.start", "pass", "definitions", "files", itoa_log(file_count));@@ -249,7 +246,6 @@ int cbm_pipeline_pass_definitions(cbm_pipeline_ctx_t *ctx, const cbm_file_info_tchar props[2048];build_def_props(props, sizeof(props), def);- // NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard headerint64_t node_id =cbm_gbuf_upsert_node(ctx->gbuf, def->label ? def->label : "Function", def->name,def->qualified_name, def->file_path ? def->file_path : rel,diff --git a/src/pipeline/pass_enrichment.c b/src/pipeline/pass_enrichment.cindex 4f91d8d40..90c5fd4b0 100644--- a/src/pipeline/pass_enrichment.c+++ b/src/pipeline/pass_enrichment.c@@ -46,7 +46,6 @@ int cbm_split_camel_case(const char *s, char **out, int max_out) {for (size_t i = 1; i < len; i++) {if (s[i] >= 'A' && s[i] <= 'Z' && s[i - 1] >= 'a' && s[i - 1] <= 'z') {if (count < max_out) {- // NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard headerout[count] = cbm_strndup(s + start, i - start);count++;}@@ -106,7 +105,6 @@ int cbm_tokenize_decorator(const char *dec, char **out, int max_out) {/* Process each part: split camelCase, lowercase, filter stopwords */int count = 0;char *saveptr = NULL;- // NOLINTNEXTLINE(misc-include-cleaner) — strtok_r provided by standard headerchar *part = strtok_r(p, " ", &saveptr);while (part && count < max_out) {@@ -147,7 +145,6 @@ int cbm_tokenize_decorator(const char *dec, char **out, int max_out) {/* Per-node tokenization state */typedef struct {- // NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard headerint64_t node_id;char *qualified_name;char **words;@@ -179,7 +176,6 @@ static char **extract_decorators_from_json(const char *json) {return NULL;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **out = calloc(cnt + 1, sizeof(char *));size_t idx = 0;yyjson_val *item;@@ -187,7 +183,6 @@ static char **extract_decorators_from_json(const char *json) {yyjson_arr_iter_init(decs, &iter);while ((item = yyjson_arr_iter_next(&iter))) {if (yyjson_is_str(item)) {- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerout[idx++] = strdup(yyjson_get_str(item));}}@@ -197,7 +192,6 @@ static char **extract_decorators_from_json(const char *json) {if (idx > 0) {return out;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out);return NULL;}@@ -229,7 +223,6 @@ static int extract_decorator_words(const char *json, char ***out_words) {}free(decorators[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(decorators);cbm_ht_free(seen);@@ -238,9 +231,7 @@ static int extract_decorator_words(const char *json, char ***out_words) {return 0;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)*out_words = malloc(sizeof(char *) * total);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)memcpy(*out_words, all_words, sizeof(char *) * total);return total;}@@ -319,16 +310,13 @@ int cbm_pipeline_pass_decorator_tags(cbm_gbuf_t *gbuf, const char *project) {tagged_node_t *tn = &nodes[node_count++];tn->node_id = found[i]->id;- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headertn->qualified_name = strdup(found[i]->qualified_name);tn->words = words;tn->word_count = wc;/* Update word counts */for (int w = 0; w < wc; w++) {- // NOLINTNEXTLINE(misc-include-cleaner) — intptr_t provided by standard headerintptr_t cnt = (intptr_t)cbm_ht_get(word_counts, words[w]);- // NOLINTNEXTLINE(performance-no-int-to-ptr)cbm_ht_set(word_counts, words[w], (void *)(cnt + 1));}}@@ -362,7 +350,6 @@ int cbm_pipeline_pass_decorator_tags(cbm_gbuf_t *gbuf, const char *project) {for (int w = 0; w < nodes[n].word_count; w++) {free(nodes[n].words[w]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(nodes[n].words);}free(nodes);@@ -387,7 +374,6 @@ int cbm_pipeline_pass_decorator_tags(cbm_gbuf_t *gbuf, const char *project) {}/* Sort tags alphabetically */- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)qsort(tag_words, tag_count, sizeof(char *), cmp_str);/* Look up node in gbuf (borrowed pointer) */@@ -414,7 +400,6 @@ int cbm_pipeline_pass_decorator_tags(cbm_gbuf_t *gbuf, const char *project) {for (int w = 0; w < nodes[n].word_count; w++) {free(nodes[n].words[w]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(nodes[n].words);}free(nodes);diff --git a/src/pipeline/pass_envscan.c b/src/pipeline/pass_envscan.cindex af8e64281..904751011 100644--- a/src/pipeline/pass_envscan.c+++ b/src/pipeline/pass_envscan.c@@ -7,10 +7,8 @@** Port of internal/pipeline/envscan.go:ScanProjectEnvURLs().*/-// NOLINTNEXTLINE(misc-include-cleaner) — pipeline.h included for interface contract#include "pipeline/pipeline.h"#include "pipeline/pipeline_internal.h"-// NOLINTNEXTLINE(misc-include-cleaner) — log.h included for interface contract#include "foundation/log.h"#include <ctype.h>diff --git a/src/pipeline/pass_gitdiff.c b/src/pipeline/pass_gitdiff.cindex 2779fa19c..a23fc0d23 100644--- a/src/pipeline/pass_gitdiff.c+++ b/src/pipeline/pass_gitdiff.c@@ -4,7 +4,6 @@* Pure string parsers for git diff --name-status and --unified=0 output.* No git execution — just parsing pre-captured output strings.*/-// NOLINTNEXTLINE(misc-include-cleaner) — pipeline.h included for interface contract#include "pipeline/pipeline.h"#include "pipeline/pipeline_internal.h"@@ -12,7 +11,6 @@#include <stdlib.h>#include <string.h>-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)void cbm_parse_range(const char *s, int *out_start, int *out_count) {*out_start = 0;*out_count = 1;diff --git a/src/pipeline/pass_githistory.c b/src/pipeline/pass_githistory.cindex 95112d29d..f9e9a7d59 100644--- a/src/pipeline/pass_githistory.c+++ b/src/pipeline/pass_githistory.c@@ -38,7 +38,6 @@ static const char *itoa_log(int val) {static bool ends_with(const char *s, size_t slen, const char *suffix) {size_t sflen = strlen(suffix);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return slen >= sflen && strcmp(s + slen - sflen, suffix) == 0;}@@ -87,10 +86,8 @@ typedef struct {static void commit_add_file(commit_t *c, const char *file) {if (c->count >= c->cap) {c->cap = c->cap ? c->cap * 2 : 16;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)c->files = safe_realloc(c->files, c->cap * sizeof(char *));}- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerc->files[c->count++] = strdup(file);}@@ -98,7 +95,6 @@ static void commit_free(commit_t *c) {for (int i = 0; i < c->count; i++) {free(c->files[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(c->files);}@@ -226,7 +222,6 @@ static int parse_git_log(const char *repo_path, commit_t **out, int *out_count)"--since='1 year ago' --max-count=10000 2>/dev/null",repo_path);- // NOLINTNEXTLINE(bugprone-command-processor,cert-env33-c)FILE *fp = cbm_popen(cmd, "r");if (!fp) {return -1;@@ -282,7 +277,6 @@ static int parse_git_log(const char *repo_path, commit_t **out, int *out_count)#endif /* HAVE_LIBGIT2 *//* Callback to free hash table entries. */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_counter(const char *key, void *val, void *ud) {(void)ud;free((void *)key);@@ -299,7 +293,6 @@ typedef struct {int max_out;} collect_coupling_ctx_t;-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void collect_coupling_cb(const char *pair_key, void *val, void *ud) {collect_coupling_ctx_t *cctx = ud;int co_count = *(int *)val;diff --git a/src/pipeline/pass_httplinks.c b/src/pipeline/pass_httplinks.cindex 73066f55c..430df797e 100644--- a/src/pipeline/pass_httplinks.c+++ b/src/pipeline/pass_httplinks.c@@ -17,13 +17,11 @@** Depends on: pass_definitions, pass_calls (for cross-file prefix resolution)*/-// NOLINTNEXTLINE(misc-include-cleaner) — pipeline.h included for interface contract#include "pipeline/pipeline.h"#include "pipeline/pipeline_internal.h"#include "pipeline/httplink.h"#include "pipeline/worker_pool.h"#include "graph_buffer/graph_buffer.h"-// NOLINTNEXTLINE(misc-include-cleaner) — platform.h included for worker count#include "foundation/platform.h"#include "foundation/log.h"#include "foundation/compat.h"@@ -86,7 +84,6 @@ static char *read_full_source(const cbm_pipeline_ctx_t *ctx, const char *rel_pat}size_t nread = fread(source, 1, (size_t)sz, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)source[nread] = '\0';return source;}@@ -119,7 +116,6 @@ static char **extract_decorators(const char *json, int *out_count) {return NULL;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **out = calloc(cnt + 1, sizeof(char *));int idx = 0;yyjson_val *item;@@ -127,7 +123,6 @@ static char **extract_decorators(const char *json, int *out_count) {yyjson_arr_iter_init(decs, &iter);while ((item = yyjson_arr_iter_next(&iter))) {if (yyjson_is_str(item)) {- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerchar *s = strdup(yyjson_get_str(item));/* Collapse newlines to spaces so regex matches multiline decorators.* POSIX regex [[:space:]] may not match \n on all platforms. */@@ -148,7 +143,6 @@ static char **extract_decorators(const char *json, int *out_count) {if (idx > 0) {return out;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out);return NULL;}@@ -169,7 +163,6 @@ static bool is_test_from_json(const char *json) {}yyjson_val *root = yyjson_doc_get_root(doc);yyjson_val *v = yyjson_obj_get(root, "is_test");- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool result = v && yyjson_is_bool(v) && yyjson_get_bool(v);yyjson_doc_free(doc);return result;@@ -220,7 +213,6 @@ static void free_decorators(char **decs) {for (int i = 0; decs[i]; i++) {free(decs[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(decs);}@@ -236,7 +228,6 @@ static bool has_suffix(const char *s, const char *suffix) {}static bool is_jsts_file(const char *path) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_suffix(path, ".js") || has_suffix(path, ".ts") || has_suffix(path, ".mjs") ||has_suffix(path, ".mts") || has_suffix(path, ".tsx");}@@ -936,7 +927,6 @@ static int insert_route_nodes(cbm_pipeline_ctx_t *ctx, cbm_route_handler_t *routchar h_props_json[2048] = "{}";int h_start = 0;int h_end = 0;- // NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard headerint64_t h_id = 0;if (handler_node) {if (handler_node->file_path) {@@ -1067,7 +1057,6 @@ static int match_and_link(cbm_pipeline_ctx_t *ctx, cbm_route_handler_t *routes,}/* Create edge */- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *edge_type = cs->is_async ? "ASYNC_CALLS" : "HTTP_CALLS";const char *band = cbm_confidence_band(score);@@ -1214,7 +1203,6 @@ static void hl_site_worker(int worker_id, void *arg) {continue;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool is_async = has_async && !has_http;/* Extract URL paths */@@ -1368,7 +1356,6 @@ int cbm_pipeline_pass_httplinks(cbm_pipeline_ctx_t *ctx) {if (total_site_nodes > 0) {all_site_nodes = malloc((size_t)total_site_nodes * sizeof(cbm_gbuf_node_t *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)all_site_labels = malloc((size_t)total_site_nodes * sizeof(const char *));}@@ -1413,9 +1400,7 @@ int cbm_pipeline_pass_httplinks(cbm_pipeline_ctx_t *ctx) {}free(site_bufs);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(all_site_nodes);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(all_site_labels);}diff --git a/src/pipeline/pass_infrascan.c b/src/pipeline/pass_infrascan.cindex d19439e9e..fa5249e6b 100644--- a/src/pipeline/pass_infrascan.c+++ b/src/pipeline/pass_infrascan.c@@ -45,7 +45,6 @@ static const char *ci_strstr(const char *haystack, const char *needle) {}size_t nlen = strlen(needle);for (; *haystack; haystack++) {- // NOLINTNEXTLINE(misc-include-cleaner) — strncasecmp provided by standard headerif (strncasecmp(haystack, needle, nlen) == 0) {return haystack;}@@ -139,7 +138,6 @@ bool cbm_is_compose_file(const char *name) {char lower[256];to_lower(name, lower, sizeof(lower));- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool prefix_match = (strncmp(lower, "docker-compose", LEN_DOCKER_COMPOSE) == 0) ||(strcmp(lower, "compose.yml") == 0) || (strcmp(lower, "compose.yaml") == 0);if (!prefix_match) {@@ -150,7 +148,6 @@ bool cbm_is_compose_file(const char *name) {if (!ext) {return false;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (strcmp(ext, ".yml") == 0 || strcmp(ext, ".yaml") == 0);}@@ -168,7 +165,6 @@ bool cbm_is_cloudbuild_file(const char *name) {if (!ext) {return false;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (strcmp(ext, ".yml") == 0 || strcmp(ext, ".yaml") == 0);}@@ -204,7 +200,6 @@ bool cbm_is_kustomize_file(const char *name) {return strcmp(lower, "kustomization.yml") == 0;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)bool cbm_is_k8s_manifest(const char *name, const char *content) {if (!name || !content || cbm_is_kustomize_file(name)) {return false;@@ -217,13 +212,11 @@ bool cbm_is_k8s_manifest(const char *name, const char *content) {return ci_strstr(buf, "apiVersion:") != NULL;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)bool cbm_is_shell_script(const char *name, const char *ext) {(void)name;if (!ext) {return false;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return (strcmp(ext, ".sh") == 0 || strcmp(ext, ".bash") == 0 || strcmp(ext, ".zsh") == 0);}@@ -292,7 +285,6 @@ bool cbm_is_secret_value(const char *value) {return false;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)bool cbm_is_secret_binding(const char *key, const char *value) {if (key && key_is_secret(key)) {return true;@@ -861,10 +853,8 @@ int cbm_parse_shell_source(const char *source, cbm_shell_result_t *out) {/* Result is non-empty if we have more than just infra_type.* In Go: len(props) > 1, where props always has infra_type.* Here: check if we have shebang OR env_vars OR sources OR docker_cmds. */- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool has_content = out->shebang[0] != '\0' || out->env_count > 0 || out->source_count > 0 ||out->docker_cmd_count > 0;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_content ? 0 : -1;}@@ -879,7 +869,6 @@ typedef enum {/* Extract a double-quoted string value after = sign.* Handles: key = "value" and key = value */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void tf_extract_quoted(const char *line, const char *prefix, char *out, size_t out_sz) {const char *p = skip_ws(line);size_t plen = strlen(prefix);@@ -1154,17 +1143,14 @@ int cbm_parse_terraform_source(const char *source, cbm_terraform_result_t *out)}/* Check if we extracted anything useful */- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool has_content = out->resource_count > 0 || out->variable_count > 0 ||out->output_count > 0 || out->provider_count > 0 || out->module_count > 0 ||out->data_source_count > 0 || out->backend[0] != '\0' || out->has_locals;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return has_content ? 0 : -1;}/* ── Infra QN helper ────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)char *cbm_infra_qn(const char *project_name, const char *rel_path, const char *infra_type,const char *service_name) {char *base = cbm_pipeline_fqn_compute(project_name, rel_path, "");@@ -1181,6 +1167,5 @@ char *cbm_infra_qn(const char *project_name, const char *rel_path, const char *i}free(base);- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerreturn strdup(result);}diff --git a/src/pipeline/pass_k8s.c b/src/pipeline/pass_k8s.cindex b0a6aa5c3..8d08da4bf 100644--- a/src/pipeline/pass_k8s.c+++ b/src/pipeline/pass_k8s.c@@ -50,7 +50,6 @@ static char *k8s_read_file(const char *path, int *out_len) {size_t nread = fread(buf, 1, size, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';*out_len = (int)nread;return buf;@@ -82,7 +81,6 @@ static void handle_kustomize(cbm_pipeline_ctx_t *ctx, const char *path, const chreturn;}- // NOLINTNEXTLINE(misc-include-cleaner)int64_t mod_id = cbm_gbuf_upsert_node(ctx->gbuf, "Module", k8s_basename(rel_path), mod_qn,rel_path, 1, 0, "{\"source\":\"kustomize\"}");free(mod_qn);@@ -170,7 +168,6 @@ static void handle_k8s_manifest(cbm_pipeline_ctx_t *ctx, const char *path, constcontinue;}- // NOLINTNEXTLINE(misc-include-cleaner)int64_t node_id =cbm_gbuf_upsert_node(ctx->gbuf, "Resource", def->name, def->qualified_name, rel_path,(int)def->start_line, (int)def->end_line, "{\"source\":\"k8s\"}");@@ -190,7 +187,6 @@ static void handle_k8s_manifest(cbm_pipeline_ctx_t *ctx, const char *path, const/* ── Pass entry point ────────────────────────────────────────────── */-// NOLINTNEXTLINE(misc-include-cleaner) — cbm_file_info_t provided by standard headerint cbm_pipeline_pass_k8s(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files, int file_count) {cbm_log_info("pass.start", "pass", "k8s", "files", itoa_k8s(file_count));diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.cindex 460422056..dfc07a2ca 100644--- a/src/pipeline/pass_parallel.c+++ b/src/pipeline/pass_parallel.c@@ -17,7 +17,6 @@#include "foundation/compat_thread.h"#include "graph_buffer/graph_buffer.h"#include "service_patterns.h"-// NOLINTNEXTLINE(misc-include-cleaner) — platform.h included for interface contract#include "foundation/platform.h"#include "foundation/log.h"#include "foundation/slab_alloc.h"@@ -61,7 +60,6 @@ static char *read_file(const char *path, int *out_len) {}size_t nread = fread(buf, 1, (size_t)size, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';*out_len = (int)nread;return buf;@@ -82,7 +80,6 @@ static const char *itoa_log(int val) {}/* Append a JSON-escaped string value to buf at position *pos. */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void append_json_string(char *buf, size_t bufsize, size_t *pos, const char *key,const char *val) {if (!val || !val[0]) {@@ -209,7 +206,6 @@ static void build_def_props(char *buf, size_t bufsize, const CBMDefinition *def)/* Build import map from graph buffer IMPORTS edges (read-only access to gbuf). */static int build_import_map(const cbm_gbuf_t *gbuf, const char *project_name, const char *rel_path,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)const char ***out_keys, const char ***out_vals, int *out_count) {*out_keys = NULL;*out_vals = NULL;@@ -230,9 +226,7 @@ static int build_import_map(const cbm_gbuf_t *gbuf, const char *project_name, coreturn 0;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **keys = calloc(edge_count, sizeof(const char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **vals = calloc(edge_count, sizeof(const char *));int count = 0;@@ -247,7 +241,6 @@ static int build_import_map(const cbm_gbuf_t *gbuf, const char *project_name, costart += strlen("\"local_name\":\"");const char *end = strchr(start, '"');if (end && end > start) {- // NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard headerkeys[count] = cbm_strndup(start, end - start);vals[count] = target->qualified_name;count++;@@ -325,11 +318,9 @@ static void extract_decorator_func(const char *dec, char *out, size_t outsz) {typedef struct {int idx;- // NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard headerint64_t size;} file_sort_entry_t;-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int compare_by_size_desc(const void *a, const void *b) {const file_sort_entry_t *fa = a;const file_sort_entry_t *fb = b;@@ -354,7 +345,6 @@ typedef struct __attribute__((aligned(CBM_CACHE_LINE))) {} extract_worker_state_t;typedef struct {- // NOLINTNEXTLINE(misc-include-cleaner) — cbm_file_info_t provided by standard headerconst cbm_file_info_t *files;file_sort_entry_t *sorted;int file_count;@@ -1093,7 +1083,6 @@ static void resolve_worker(int worker_id, void *ctx_ptr) {continue;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *edge_type = is_checked_exception(thr->exception_name) ? "THROWS" : "RAISES";cbm_resolution_t res = cbm_registry_resolve(rc->registry, thr->exception_name,module_qn, imp_keys, imp_vals, imp_count);@@ -1140,7 +1129,6 @@ static void resolve_worker(int worker_id, void *ctx_ptr) {continue;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *etype = rw->is_write ? "WRITES" : "READS";cbm_gbuf_insert_edge(ws->local_edge_buf, src->id, tgt->id, etype, "{}");}diff --git a/src/pipeline/pass_semantic.c b/src/pipeline/pass_semantic.cindex e2d81ce3e..d84e93740 100644--- a/src/pipeline/pass_semantic.c+++ b/src/pipeline/pass_semantic.c@@ -41,7 +41,6 @@ static char *read_file(const char *path, int *out_len) {}size_t nread = fread(buf, 1, size, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';*out_len = (int)nread;return buf;@@ -58,7 +57,6 @@ static const char *itoa_log(int val) {/* Build per-file import map from cached extraction result or graph buffer edges. */static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)const CBMFileResult *result, const char ***out_keys,const char ***out_vals, int *out_count) {*out_keys = NULL;@@ -67,9 +65,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,/* Fast path: build from cached extraction result (no JSON parsing) */if (result && result->imports.count > 0) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **keys = calloc((size_t)result->imports.count, sizeof(const char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **vals = calloc((size_t)result->imports.count, sizeof(const char *));int count = 0;@@ -84,7 +80,6 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,if (!target) {continue;}- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerkeys[count] = strdup(imp->local_name);vals[count] = target->qualified_name;count++;@@ -112,9 +107,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,return 0;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **keys = calloc(edge_count, sizeof(const char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **vals = calloc(edge_count, sizeof(const char *));int count = 0;@@ -130,7 +123,6 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,start += strlen("\"local_name\":\"");const char *end = strchr(start, '"');if (end && end > start) {- // NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard headerkeys[count] = cbm_strndup(start, end - start);vals[count] = target->qualified_name;count++;@@ -207,7 +199,6 @@ static bool fp_ends_with(const char *fp, const char *suffix) {}size_t fplen = strlen(fp);size_t sflen = strlen(suffix);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return fplen >= sflen && strcmp(fp + fplen - sflen, suffix) == 0;}@@ -247,7 +238,6 @@ int cbm_pipeline_implements_go(cbm_pipeline_ctx_t *ctx) {/* Collect interface method info */typedef struct {const char *name;- // NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard headerint64_t id;} imethod_t;imethod_t imethods[128];@@ -309,7 +299,6 @@ int cbm_pipeline_implements_go(cbm_pipeline_ctx_t *ctx) {return edge_count;}-// NOLINTNEXTLINE(misc-include-cleaner) — cbm_file_info_t provided by standard headerint cbm_pipeline_pass_semantic(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,int file_count) {cbm_log_info("pass.start", "pass", "semantic", "files", itoa_log(file_count));diff --git a/src/pipeline/pass_tests.c b/src/pipeline/pass_tests.cindex e1e0512b3..540eba735 100644--- a/src/pipeline/pass_tests.c+++ b/src/pipeline/pass_tests.c@@ -38,7 +38,6 @@ static bool node_is_test(const cbm_gbuf_node_t *n) {/* Helper to check suffix. */static bool str_ends_with(const char *s, size_t slen, const char *suffix) {size_t sflen = strlen(suffix);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)return slen >= sflen && strcmp(s + slen - sflen, suffix) == 0;}@@ -209,7 +208,6 @@ static char *test_to_prod_path(const char *test_path) {return NULL;}-// NOLINTNEXTLINE(misc-include-cleaner) — cbm_file_info_t provided by standard headerint cbm_pipeline_pass_tests(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files, int file_count) {cbm_log_info("pass.start", "pass", "tests");(void)files;@@ -234,14 +232,12 @@ int cbm_pipeline_pass_tests(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *file/* Source must be a test, target must not */bool src_is_test =- // NOLINTNEXTLINE(readability-implicit-bool-conversion)node_is_test(src) || (src->file_path && cbm_is_test_path(src->file_path));if (!src_is_test) {continue;}bool tgt_is_test =- // NOLINTNEXTLINE(readability-implicit-bool-conversion)node_is_test(tgt) || (tgt->file_path && cbm_is_test_path(tgt->file_path));if (tgt_is_test) {continue;diff --git a/src/pipeline/pass_usages.c b/src/pipeline/pass_usages.cindex a77ec835c..c0573ca90 100644--- a/src/pipeline/pass_usages.c+++ b/src/pipeline/pass_usages.c@@ -42,7 +42,6 @@ static char *read_file(const char *path, int *out_len) {}size_t nread = fread(buf, 1, size, f);(void)fclose(f);- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)buf[nread] = '\0';*out_len = (int)nread;return buf;@@ -73,7 +72,6 @@ static bool is_checked_exception(const char *name) {/* Build per-file import map from cached extraction result or graph buffer edges. */static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)const CBMFileResult *result, const char ***out_keys,const char ***out_vals, int *out_count) {*out_keys = NULL;@@ -82,9 +80,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,/* Fast path: build from cached extraction result (no JSON parsing) */if (result && result->imports.count > 0) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **keys = calloc((size_t)result->imports.count, sizeof(const char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **vals = calloc((size_t)result->imports.count, sizeof(const char *));int count = 0;@@ -99,7 +95,6 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,if (!target) {continue;}- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerkeys[count] = strdup(imp->local_name);vals[count] = target->qualified_name;count++;@@ -127,9 +122,7 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,return 0;}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **keys = calloc(edge_count, sizeof(const char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)const char **vals = calloc(edge_count, sizeof(const char *));int count = 0;@@ -146,7 +139,6 @@ static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,start += strlen("\"local_name\":\"");const char *end = strchr(start, '"');if (end && end > start) {- // NOLINTNEXTLINE(misc-include-cleaner) — strndup provided by standard headerkeys[count] = cbm_strndup(start, end - start);vals[count] = target->qualified_name;count++;@@ -174,7 +166,6 @@ static void free_import_map(const char **keys, const char **vals, int count) {}/* Find the graph buffer node for an enclosing function QN, falling back to file node. */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static const cbm_gbuf_node_t *find_enclosing_node(cbm_pipeline_ctx_t *ctx, const char *func_qn,const char *rel_path) {const cbm_gbuf_node_t *node = NULL;@@ -189,7 +180,6 @@ static const cbm_gbuf_node_t *find_enclosing_node(cbm_pipeline_ctx_t *ctx, constreturn node;}-// NOLINTNEXTLINE(misc-include-cleaner) — cbm_file_info_t provided by standard headerint cbm_pipeline_pass_usages(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,int file_count) {cbm_log_info("pass.start", "pass", "usages", "files", itoa_log(file_count));@@ -295,7 +285,6 @@ int cbm_pipeline_pass_usages(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *filcontinue;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *edge_type = is_checked_exception(thr->exception_name) ? "THROWS" : "RAISES";/* Try to resolve exception class */@@ -341,7 +330,6 @@ int cbm_pipeline_pass_usages(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *filcontinue;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *edge_type = rw->is_write ? "WRITES" : "READS";cbm_gbuf_insert_edge(ctx->gbuf, src->id, tgt->id, edge_type, "{}");rw_resolved++;diff --git a/src/pipeline/pipeline.c b/src/pipeline/pipeline.cindex 4e2ce5b24..8a30bf792 100644--- a/src/pipeline/pipeline.c+++ b/src/pipeline/pipeline.c@@ -12,7 +12,6 @@*/#include "pipeline/pipeline.h"#include "pipeline/pipeline_internal.h"-// NOLINTNEXTLINE(misc-include-cleaner) — worker_pool.h included for interface contract#include "pipeline/worker_pool.h"#include "graph_buffer/graph_buffer.h"#include "store/store.h"@@ -76,7 +75,6 @@ struct cbm_pipeline {static double elapsed_ms(struct timespec start) {struct timespec now;- // NOLINTNEXTLINE(misc-include-cleaner) — cbm_clock_gettime provided by standard headercbm_clock_gettime(CLOCK_MONOTONIC, &now);return ((double)(now.tv_sec - start.tv_sec) * CBM_MS_PER_SEC) +((double)(now.tv_nsec - start.tv_nsec) / CBM_US_PER_SEC_F);@@ -105,7 +103,6 @@ cbm_pipeline_t *cbm_pipeline_new(const char *repo_path, const char *db_path,return NULL;}- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headerp->repo_path = strdup(repo_path);p->db_path = db_path ? strdup(db_path) : NULL;p->project_name = cbm_project_name_from_path(repo_path);@@ -174,7 +171,6 @@ static int check_cancel(const cbm_pipeline_t *p) {/* ── Hash table cleanup callback ─────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_seen_dir_key(const char *key, void *val, void *ud) {(void)val;(void)ud;@@ -531,7 +527,6 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {/* Decide: parallel or sequential pipeline */int worker_count = cbm_default_worker_count(true);#define MIN_FILES_FOR_PARALLEL 50- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool use_parallel = (worker_count > 1 && file_count > MIN_FILES_FOR_PARALLEL);if (use_parallel) {@@ -539,13 +534,11 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {"files", itoa_buf(file_count));/* Shared atomic ID source — workers allocate globally unique IDs */- // NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard header_Atomic int64_t shared_ids;int64_t gbuf_next = cbm_gbuf_next_id(p->gbuf);atomic_init(&shared_ids, gbuf_next);/* Allocate result cache: one CBMFileResult* per file */- // NOLINTNEXTLINE(misc-include-cleaner)CBMFileResult **result_cache =(CBMFileResult **)calloc(file_count, sizeof(CBMFileResult *));if (!result_cache) {@@ -560,12 +553,10 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {cbm_log_info("pass.timing", "pass", "parallel_extract", "elapsed_ms",itoa_buf((int)elapsed_ms(t)));if (rc != 0) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(result_cache);goto cleanup;}if (check_cancel(p)) {- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(result_cache);rc = -1;goto cleanup;@@ -582,11 +573,9 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {if (rc != 0) {for (int i = 0; i < file_count; i++) {if (result_cache[i]) {- // NOLINTNEXTLINE(misc-include-cleaner)cbm_free_result(result_cache[i]);}}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(result_cache);goto cleanup;}@@ -596,7 +585,6 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {cbm_free_result(result_cache[i]);}}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(result_cache);rc = -1;goto cleanup;@@ -623,7 +611,6 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {cbm_free_result(result_cache[i]);}}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(result_cache);if (rc != 0) {@@ -648,7 +635,6 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {/* Allocate result cache: pass_definitions stores results for reuse* by pass_calls/usages/semantic, avoiding 3x redundant file I/O + parsing */- // NOLINTNEXTLINE(misc-include-cleaner)CBMFileResult **seq_cache = (CBMFileResult **)calloc(file_count, sizeof(CBMFileResult *));if (seq_cache) {ctx.result_cache = seq_cache;@@ -718,7 +704,6 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {cbm_free_result(seq_cache[i]);}}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(seq_cache);ctx.result_cache = NULL;}diff --git a/src/pipeline/pipeline_incremental.c b/src/pipeline/pipeline_incremental.cindex 3ba8bbdd0..3b9e3e772 100644--- a/src/pipeline/pipeline_incremental.c+++ b/src/pipeline/pipeline_incremental.c@@ -314,7 +314,6 @@ int cbm_pipeline_run_incremental(cbm_pipeline_t *p, const char *db_path, cbm_fil#define MIN_FILES_FOR_PARALLEL_INCR 50int worker_count = cbm_default_worker_count(true);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool use_parallel = (worker_count > 1 && ci > MIN_FILES_FOR_PARALLEL_INCR);if (use_parallel) {diff --git a/src/pipeline/registry.c b/src/pipeline/registry.cindex 6b70683cb..68c2dad68 100644--- a/src/pipeline/registry.c+++ b/src/pipeline/registry.c@@ -147,14 +147,12 @@ cbm_registry_t *cbm_registry_new(void) {return r;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_label(const char *key, void *value, void *ud) {(void)ud;free((void *)key);free(value);}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_qn_array(const char *key, void *value, void *ud) {(void)ud;qn_array_t *arr = value;@@ -162,7 +160,6 @@ static void free_qn_array(const char *key, void *value, void *ud) {for (int i = 0; i < arr->count; i++) {free(arr->items[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_free(arr);free(arr);}@@ -182,7 +179,6 @@ void cbm_registry_free(cbm_registry_t *r) {/* ── Registration ────────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)void cbm_registry_add(cbm_registry_t *r, const char *name, const char *qualified_name,const char *label) {(void)name;@@ -196,7 +192,6 @@ void cbm_registry_add(cbm_registry_t *r, const char *name, const char *qualified}/* Store in exact map: QN → label */- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headercbm_ht_set(r->exact, strdup(qualified_name), strdup(label));/* Index by simple name.@@ -207,7 +202,6 @@ void cbm_registry_add(cbm_registry_t *r, const char *name, const char *qualifiedarr = calloc(1, sizeof(qn_array_t));cbm_ht_set(r->by_name, strdup(simple), arr);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)cbm_da_push(arr, strdup(qualified_name));}@@ -258,7 +252,6 @@ struct ims_ctx {const char *found_key;};-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void ims_scan(const char *key, void *value, void *ud) {(void)value;struct ims_ctx *ctx = ud;@@ -274,7 +267,6 @@ static void ims_scan(const char *key, void *value, void *ud) {}/* Strategy 1: Import map lookup (exact → suffix fallback) */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static cbm_resolution_t resolve_import_map(const cbm_registry_t *r, const char *prefix,const char *suffix, const char **keys, const char **vals,int map_count) {@@ -331,7 +323,6 @@ static cbm_resolution_t resolve_import_map(const cbm_registry_t *r, const char *}/* Strategy 2: Same-module match */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static cbm_resolution_t resolve_same_module(const cbm_registry_t *r, const char *callee_name,const char *suffix, const char *module_qn) {char candidate[512];@@ -351,7 +342,6 @@ static cbm_resolution_t resolve_same_module(const cbm_registry_t *r, const char}/* Strategy 3+4: Name lookup + suffix match */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static cbm_resolution_t resolve_name_lookup(const cbm_registry_t *r, const char *callee_name,const char *module_qn, const char **import_vals,int import_count) {@@ -483,7 +473,6 @@ cbm_fuzzy_result_t cbm_registry_fuzzy_resolve(const cbm_registry_t *r, const chareturn no_match;}- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool have_imports = (import_map_vals && import_map_count > 0);/* Single candidate */@@ -542,7 +531,6 @@ struct few_ctx {int cap;};-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void few_scan(const char *key, void *value, void *ud) {(void)value;struct few_ctx *ctx = ud;@@ -550,7 +538,6 @@ static void few_scan(const char *key, void *value, void *ud) {if (klen >= ctx->target_len && strcmp(key + klen - ctx->target_len, ctx->target) == 0) {if (ctx->count >= ctx->cap) {ctx->cap = ctx->cap ? ctx->cap * 2 : 16;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)ctx->results = safe_realloc(ctx->results, (size_t)ctx->cap * sizeof(char *));}ctx->results[ctx->count++] = key;diff --git a/src/pipeline/worker_pool.c b/src/pipeline/worker_pool.cindex b107818b0..63976b8cc 100644--- a/src/pipeline/worker_pool.c+++ b/src/pipeline/worker_pool.c@@ -48,7 +48,6 @@ static void *pthread_worker(void *arg) {return NULL;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void run_pthreads(int count, cbm_parallel_fn fn, void *ctx, int nworkers) {_Atomic int next_idx = 0;diff --git a/src/store/store.c b/src/store/store.cindex 88aa7078c..966bf1682 100644--- a/src/store/store.c+++ b/src/store/store.c@@ -25,7 +25,6 @@/* Wrap sqlite3_bind_text with SQLITE_TRANSIENT to isolate the platformint-to-pointer cast ((void*)-1) in one place. */-// NOLINTNEXTLINE(performance-no-int-to-ptr)static const sqlite3_destructor_type BIND_TRANSIENT = SQLITE_TRANSIENT;static int bind_text(sqlite3_stmt *s, int col, const char *v) {@@ -750,7 +749,6 @@ int cbm_store_delete_project(cbm_store_t *s, const char *name) {/* ── Node CRUD ──────────────────────────────────────────────────── */-// NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard headerint64_t cbm_store_upsert_node(cbm_store_t *s, const cbm_node_t *n) {sqlite3_stmt *stmt =prepare_cached(s, &s->stmt_upsert_node,@@ -789,7 +787,6 @@ static void scan_node(sqlite3_stmt *stmt, cbm_node_t *n) {n->id = sqlite3_column_int64(stmt, 0);n->project = heap_strdup((const char *)sqlite3_column_text(stmt, 1));n->label = heap_strdup((const char *)sqlite3_column_text(stmt, 2));- // NOLINTNEXTLINE(clang-analyzer-unix.Malloc)n->name = heap_strdup((const char *)sqlite3_column_text(stmt, 3));n->qualified_name = heap_strdup((const char *)sqlite3_column_text(stmt, 4));n->file_path = heap_strdup((const char *)sqlite3_column_text(stmt, 5));@@ -925,7 +922,6 @@ int cbm_store_find_node_ids_by_qns(cbm_store_t *s, const char *project, const ch}/* Generic: find multiple nodes by a single-column filter. */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int find_nodes_generic(cbm_store_t *s, sqlite3_stmt **slot, const char *sql,const char *project, const char *val, cbm_node_t **out, int *count) {if (!s || !s->db) {@@ -1499,7 +1495,6 @@ int cbm_store_find_nodes_by_qn_suffix(cbm_store_t *s, const char *project, const/* ── NodeDegree ────────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)void cbm_store_node_degree(cbm_store_t *s, int64_t node_id, int *in_deg, int *out_deg) {*in_deg = 0;*out_deg = 0;@@ -1563,7 +1558,6 @@ int cbm_store_list_files(cbm_store_t *s, const char *project, char ***out, int */* ── Node neighbor names ──────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int query_neighbor_names(sqlite3 *db, const char *sql, int64_t node_id, int limit,char ***out, int *out_count) {*out = NULL;@@ -1576,7 +1570,6 @@ static int query_neighbor_names(sqlite3 *db, const char *sql, int64_t node_id, isqlite3_bind_int(stmt, 2, limit);int cap = 8;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **names = malloc((size_t)cap * sizeof(char *));int count = 0;while (sqlite3_step(stmt) == SQLITE_ROW) {@@ -1586,10 +1579,8 @@ static int query_neighbor_names(sqlite3 *db, const char *sql, int64_t node_id, i}if (count >= cap) {cap *= 2;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)names = safe_realloc(names, (size_t)cap * sizeof(char *));}- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headernames[count++] = strdup(name);}sqlite3_finalize(stmt);@@ -1645,7 +1636,6 @@ int cbm_store_batch_count_degrees(cbm_store_t *s, const int64_t *node_ids, int i}in_clause[pos] = '\0';- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool has_type = edge_type && edge_type[0] != '\0';/* Inbound: COUNT grouped by target_id */@@ -1751,7 +1741,6 @@ int cbm_store_upsert_file_hash_batch(cbm_store_t *s, const cbm_file_hash_t *hash/* ── FindEdgesByURLPath ────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_store_find_edges_by_url_path(cbm_store_t *s, const char *project, const char *keyword,cbm_edge_t **out, int *count) {*out = NULL;@@ -2050,7 +2039,6 @@ int cbm_store_search(cbm_store_t *s, const cbm_search_params_t *params, cbm_sear/* Degree filters: -1 = no filter, 0+ = active filter.* Wraps in subquery to filter on computed degree columns. */- // NOLINTNEXTLINE(readability-implicit-bool-conversion)bool has_degree_filter = (params->min_degree >= 0 || params->max_degree >= 0);if (has_degree_filter) {char inner_sql[4096];@@ -2077,7 +2065,6 @@ int cbm_store_search(cbm_store_t *s, const cbm_search_params_t *params, cbm_searint limit = params->limit > 0 ? params->limit : 500000;int offset = params->offset;bool has_degree_wrap = has_degree_filter;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *name_col = has_degree_wrap ? "name" : "n.name";char order_limit[128];snprintf(order_limit, sizeof(order_limit), " ORDER BY %s LIMIT %d OFFSET %d", name_col, limit,@@ -2149,7 +2136,6 @@ void cbm_store_search_free(cbm_search_output_t *out) {for (int j = 0; j < r->connected_count; j++) {free((void *)r->connected_names[j]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(r->connected_names);}free(out->results);@@ -2159,7 +2145,6 @@ void cbm_store_search_free(cbm_search_output_t *out) {/* ── BFS Traversal ──────────────────────────────────────────────── */int cbm_store_bfs(cbm_store_t *s, int64_t start_id, const char *direction, const char **edge_types,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int edge_type_count, int max_depth, int max_results, cbm_traverse_result_t *out) {memset(out, 0, sizeof(*out));@@ -2195,8 +2180,7 @@ int cbm_store_bfs(cbm_store_t *s, int64_t start_id, const char *direction, constchar sql[4096];const char *join_cond;const char *next_id;- // NOLINTNEXTLINE(readability-implicit-bool-conversion)- bool is_inbound = direction && strcmp(direction, "inbound") == 0;+ bool is_inbound = (direction != NULL) && (strcmp(direction, "inbound") == 0);if (is_inbound) {join_cond = "e.target_id = bfs.node_id";@@ -2532,25 +2516,21 @@ void cbm_store_schema_free(cbm_schema_info_t *out) {for (int i = 0; i < out->rel_pattern_count; i++) {free((void *)out->rel_patterns[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out->rel_patterns);for (int i = 0; i < out->sample_func_count; i++) {free((void *)out->sample_func_names[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out->sample_func_names);for (int i = 0; i < out->sample_class_count; i++) {free((void *)out->sample_class_names[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out->sample_class_names);for (int i = 0; i < out->sample_qn_count; i++) {free((void *)out->sample_qns[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out->sample_qns);memset(out, 0, sizeof(*out));@@ -2619,8 +2599,10 @@ const char *cbm_qn_to_top_package(const char *qn) {}bool cbm_is_test_file_path(const char *fp) {- // NOLINTNEXTLINE(readability-implicit-bool-conversion)- return fp && fp[0] && strstr(fp, "test") != NULL;+ if (!fp || fp[0] == '\0') {+ return false;+ }+ return strstr(fp, "test") != NULL;}/* File extension → language name mapping */@@ -2812,7 +2794,6 @@ static int arch_languages(cbm_store_t *s, const char *project, cbm_architecture_nlang = 10;}- // NOLINTNEXTLINE(clang-analyzer-optin.portability.UnixAPI)out->languages = calloc(nlang, sizeof(cbm_language_count_t));out->language_count = nlang;for (int i = 0; i < nlang; i++) {@@ -2992,14 +2973,12 @@ static int arch_boundaries(cbm_store_t *s, const char *project, cbm_cross_pkg_boint ncap = 256;int nn = 0;int64_t *nids = malloc(ncap * sizeof(int64_t));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **npkgs = malloc(ncap * sizeof(char *));while (sqlite3_step(nstmt) == SQLITE_ROW) {if (nn >= ncap) {ncap *= 2;nids = safe_realloc(nids, ncap * sizeof(int64_t));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)npkgs = safe_realloc(npkgs, ncap * sizeof(char *));}nids[nn] = sqlite3_column_int64(nstmt, 0);@@ -3017,7 +2996,6 @@ static int arch_boundaries(cbm_store_t *s, const char *project, cbm_cross_pkg_bofree(npkgs[i]);}free(nids);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(npkgs);store_set_error_sqlite(s, "arch_boundaries_edges");return CBM_STORE_ERR;@@ -3027,9 +3005,7 @@ static int arch_boundaries(cbm_store_t *s, const char *project, cbm_cross_pkg_bo/* Boundary counts: parallel arrays for from→to→count */int bcap = 32;int bn = 0;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **bfroms = malloc(bcap * sizeof(char *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **btos = malloc(bcap * sizeof(char *));int *bcounts = malloc(bcap * sizeof(int));@@ -3071,7 +3047,6 @@ static int arch_boundaries(cbm_store_t *s, const char *project, cbm_cross_pkg_bofree(npkgs[i]);}free(nids);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(npkgs);/* Sort by count descending */@@ -3098,16 +3073,13 @@ static int arch_boundaries(cbm_store_t *s, const char *project, cbm_cross_pkg_bobn = 10;}- // NOLINTNEXTLINE(clang-analyzer-optin.portability.UnixAPI)cbm_cross_pkg_boundary_t *result = calloc(bn, sizeof(cbm_cross_pkg_boundary_t));for (int i = 0; i < bn; i++) {result[i].from = bfroms[i];result[i].to = btos[i];result[i].call_count = bcounts[i];}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(bfroms);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(btos);free(bcounts);*out_arr = result;@@ -3202,7 +3174,6 @@ static int arch_packages(cbm_store_t *s, const char *project, cbm_architecture_inp = MAX_PREVIEW_NAMES;}- // NOLINTNEXTLINE(clang-analyzer-optin.portability.UnixAPI)arr = calloc(np, sizeof(cbm_package_summary_t));n = np;for (int i = 0; i < np; i++) {@@ -3217,7 +3188,6 @@ static int arch_packages(cbm_store_t *s, const char *project, cbm_architecture_i}static void classify_layer(const char *pkg, int in, int out_deg, bool has_routes,- // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)bool has_entry_points, const char **layer, const char **reason) {static CBM_TLS char reason_buf[128];if (has_entry_points && out_deg > 0 && in == 0) {@@ -3364,7 +3334,6 @@ static int arch_layers(cbm_store_t *s, const char *project, cbm_architecture_inf}/* Classify each package */- // NOLINTNEXTLINE(clang-analyzer-optin.portability.UnixAPI)out->layers = calloc(npkgs, sizeof(cbm_package_layer_t));out->layer_count = npkgs;for (int i = 0; i < npkgs; i++) {@@ -3428,17 +3397,14 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_/* Collect all file paths + build directory children map */int fcap = 32;int fn = 0;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **files = malloc(fcap * sizeof(char *));/* Directory tree: parallel arrays of dir → children set */int dcap = 64;int dn = 0;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **dir_paths = calloc(dcap, sizeof(char *));int *dir_child_counts = calloc(dcap, sizeof(int));/* Track unique children per dir using a simple string array */- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char ***dir_children = calloc(dcap, sizeof(char **));int *dir_children_caps = calloc(dcap, sizeof(int));@@ -3449,7 +3415,6 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_}if (fn >= fcap) {fcap *= 2;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)files = safe_realloc(files, fcap * sizeof(char *));}files[fn++] = heap_strdup(fp);@@ -3503,7 +3468,6 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_dir_children_caps[ri] =dir_children_caps[ri] ? dir_children_caps[ri] * 2 : 4;dir_children[ri] =- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)realloc(dir_children[ri], dir_children_caps[ri] * sizeof(char *));}dir_children[ri][dir_child_counts[ri]++] = heap_strdup(parts[0]);@@ -3554,7 +3518,6 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_dir_children_caps[di] =dir_children_caps[di] ? dir_children_caps[di] * 2 : 4;dir_children[di] =- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)realloc(dir_children[di], dir_children_caps[di] * sizeof(char *));}dir_children[di][dir_child_counts[di]++] = heap_strdup(child);@@ -3598,8 +3561,11 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_}}entries[en].path = heap_strdup(child);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)- entries[en].type = heap_strdup(is_file ? "file" : "dir");+ if (is_file) {+ entries[en].type = heap_strdup("file");+ } else {+ entries[en].type = heap_strdup("dir");+ }entries[en].children = nch;en++;}@@ -3612,7 +3578,6 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_}/* Limit depth to 3 levels */int slashes = 0;- // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)for (const char *p = dir_paths[i]; *p; p++) {if (*p == '/') {slashes++;@@ -3644,8 +3609,11 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_}}entries[en].path = heap_strdup(path);- // NOLINTNEXTLINE(readability-implicit-bool-conversion)- entries[en].type = heap_strdup(is_file ? "file" : "dir");+ if (is_file) {+ entries[en].type = heap_strdup("file");+ } else {+ entries[en].type = heap_strdup("dir");+ }entries[en].children = nch;en++;}@@ -3668,19 +3636,15 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_for (int k = 0; k < dir_child_counts[i]; k++) {free(dir_children[i][k]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(dir_children[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(dir_paths);free(dir_child_counts);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(dir_children);free(dir_children_caps);for (int i = 0; i < fn; i++) {free(files[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(files);out->file_tree = entries;@@ -3753,9 +3717,7 @@ int cbm_louvain(const int64_t *nodes, int node_count, const cbm_louvain_edge_t *}/* Build adjacency lists */- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)int **adj = calloc(n, sizeof(int *));- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)double **adj_w = calloc(n, sizeof(double *));int *adj_n = calloc(n, sizeof(int));int *adj_cap = calloc(n, sizeof(int));@@ -3811,9 +3773,7 @@ int cbm_louvain(const int64_t *nodes, int node_count, const cbm_louvain_edge_t *free(adj[i]);free(adj_w[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(adj);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(adj_w);free(adj_n);free(adj_cap);@@ -3925,9 +3885,7 @@ int cbm_louvain(const int64_t *nodes, int node_count, const cbm_louvain_edge_t *free(adj[i]);free(adj_w[i]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(adj);- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(adj_w);free(adj_n);free(adj_cap);@@ -4063,17 +4021,14 @@ void cbm_store_architecture_free(cbm_architecture_info_t *out) {for (int j = 0; j < out->clusters[i].top_node_count; j++) {free((void *)out->clusters[i].top_nodes[j]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out->clusters[i].top_nodes);for (int j = 0; j < out->clusters[i].package_count; j++) {free((void *)out->clusters[i].packages[j]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out->clusters[i].packages);for (int j = 0; j < out->clusters[i].edge_type_count; j++) {free((void *)out->clusters[i].edge_types[j]);}- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)free(out->clusters[i].edge_types);}free(out->clusters);@@ -4406,7 +4361,6 @@ int cbm_store_adr_delete(cbm_store_t *s, const char *project) {return CBM_STORE_OK;}-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)int cbm_store_adr_update_sections(cbm_store_t *s, const char *project, const char **keys,const char **values, int count, cbm_adr_t *out) {/* Get existing ADR */@@ -4491,12 +4445,10 @@ int cbm_store_find_architecture_docs(cbm_store_t *s, const char *project, char *int cap = 8;int n = 0;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)char **arr = malloc(cap * sizeof(char *));while (sqlite3_step(stmt) == SQLITE_ROW) {if (n >= cap) {cap *= 2;- // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)arr = safe_realloc(arr, cap * sizeof(char *));}arr[n++] = heap_strdup((const char *)sqlite3_column_text(stmt, 0));diff --git a/src/traces/traces.c b/src/traces/traces.cindex c8ff290d8..081514650 100644--- a/src/traces/traces.c+++ b/src/traces/traces.c@@ -59,7 +59,6 @@ const char *cbm_extract_path_from_url(const char *url, char *buf, size_t buf_sz)/* ── parseDuration ───────────────────────────────────────────────── */-// NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard headerint64_t cbm_parse_duration(const char *start_nano, const char *end_nano) {if (!start_nano || !end_nano) {return 0;@@ -118,7 +117,6 @@ bool cbm_extract_http_info(const cbm_trace_span_t *span, const char *service_nam/* ── calculateP99 ────────────────────────────────────────────────── */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static int cmp_int64(const void *a, const void *b) {int64_t va = *(const int64_t *)a;int64_t vb = *(const int64_t *)b;diff --git a/src/watcher/watcher.c b/src/watcher/watcher.cindex 5c730ebf1..a50672dea 100644--- a/src/watcher/watcher.c+++ b/src/watcher/watcher.c@@ -33,12 +33,11 @@typedef struct {char *project_name;char *root_path;- char last_head[64]; /* git HEAD hash */- bool is_git; /* false → skip polling */- bool baseline_done; /* true after first poll */- int file_count; /* approximate, for interval calc */- int interval_ms; /* adaptive poll interval */- // NOLINTNEXTLINE(misc-include-cleaner) — int64_t provided by standard header+ char last_head[64]; /* git HEAD hash */+ bool is_git; /* false → skip polling */+ bool baseline_done; /* true after first poll */+ int file_count; /* approximate, for interval calc */+ int interval_ms; /* adaptive poll interval */int64_t next_poll_ns; /* next poll time (monotonic ns) */} project_state_t;@@ -70,7 +69,6 @@ struct cbm_watcher {static int64_t now_ns(void) {struct timespec ts;- // NOLINTNEXTLINE(misc-include-cleaner) — cbm_clock_gettime provided by standard headercbm_clock_gettime(CLOCK_MONOTONIC, &ts);return ((int64_t)ts.tv_sec * NS_PER_SEC) + ts.tv_nsec;}@@ -90,14 +88,12 @@ int cbm_watcher_poll_interval_ms(int file_count) {static bool is_git_repo(const char *root_path) {char cmd[1024];snprintf(cmd, sizeof(cmd), "git -C '%s' rev-parse --git-dir >/dev/null 2>&1", root_path);- // NOLINTNEXTLINE(bugprone-command-processor,cert-env33-c,concurrency-mt-unsafe)return system(cmd) == 0;}static int git_head(const char *root_path, char *out, size_t out_size) {char cmd[1024];snprintf(cmd, sizeof(cmd), "git -C '%s' rev-parse HEAD 2>/dev/null", root_path);- // NOLINTNEXTLINE(misc-include-cleaner,bugprone-command-processor,cert-env33-c)FILE *fp = cbm_popen(cmd, "r");if (!fp) {return -1;@@ -122,7 +118,6 @@ static bool git_is_dirty(const char *root_path) {"git --no-optional-locks -C '%s' status --porcelain ""--untracked-files=normal 2>/dev/null",root_path);- // NOLINTNEXTLINE(bugprone-command-processor,cert-env33-c)FILE *fp = cbm_popen(cmd, "r");if (!fp) {return false;@@ -148,7 +143,6 @@ static bool git_is_dirty(const char *root_path) {static int git_file_count(const char *root_path) {char cmd[1024];snprintf(cmd, sizeof(cmd), "git -C '%s' ls-files 2>/dev/null | wc -l", root_path);- // NOLINTNEXTLINE(bugprone-command-processor,cert-env33-c)FILE *fp = cbm_popen(cmd, "r");if (!fp) {return 0;@@ -170,7 +164,6 @@ static project_state_t *state_new(const char *name, const char *root_path) {if (!s) {return NULL;}- // NOLINTNEXTLINE(misc-include-cleaner) — strdup provided by standard headers->project_name = strdup(name);s->root_path = strdup(root_path);s->interval_ms = POLL_BASE_MS;@@ -187,7 +180,6 @@ static void state_free(project_state_t *s) {}/* Hash table foreach callback to free state entries */-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void free_state_entry(const char *key, void *val, void *ud) {(void)key;(void)ud;@@ -330,7 +322,6 @@ typedef struct {int reindexed;} poll_ctx_t;-// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)static void poll_project(const char *key, void *val, void *ud) {(void)key;poll_ctx_t *ctx = ud;diff --git a/tests/test_helpers.h b/tests/test_helpers.hnew file mode 100644index 000000000..f7d2ae6de--- /dev/null+++ b/tests/test_helpers.h@@ -0,0 +1,171 @@+/*+ * test_helpers.h — Cross-platform test fixture helpers.+ *+ * Replaces system("rm -rf"), system("mkdir -p && echo >"), chmod(),+ * and hardcoded /tmp/ paths with portable C implementations.+ * Uses compat.h/compat_fs.h underneath — same abstraction layer+ * as production code.+ *+ * All functions are static inline to avoid linker issues when+ * included from multiple test files.+ */+#ifndef TEST_HELPERS_H+#define TEST_HELPERS_H++#include "../src/foundation/compat.h"+#include "../src/foundation/compat_fs.h"++#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <sys/stat.h>++/* ── Path building ────────────────────────────────────────────── */++/* Build a path from base + relative. Uses a static buffer — not reentrant.+ * Usage: th_write_file(TH_PATH(base, "src/main.go"), "content"); */+#define TH_PATH(base, rel) th_path_join(base, rel)++static inline const char *th_path_join(const char *base, const char *rel) {+ static char buf[4][1024];+ static int idx = 0;+ int i = idx;+ idx = (idx + 1) & 3;+ snprintf(buf[i], sizeof(buf[i]), "%s/%s", base, rel);+ return buf[i];+}++/* ── File writing ─────────────────────────────────────────────── */++/* Write content to a file, creating parent directories as needed. */+static inline int th_write_file(const char *path, const char *content) {+ /* Create parent directories */+ char dir[1024];+ snprintf(dir, sizeof(dir), "%s", path);+ char *last_slash = strrchr(dir, '/');+#ifdef _WIN32+ char *last_bslash = strrchr(dir, '\\');+ if (last_bslash && (!last_slash || last_bslash > last_slash)) {+ last_slash = last_bslash;+ }+#endif+ if (last_slash) {+ *last_slash = '\0';+ cbm_mkdir_p(dir, 0755);+ }++ FILE *f = fopen(path, "w");+ if (!f) {+ return -1;+ }+ if (content && content[0]) {+ fputs(content, f);+ }+ fclose(f);+ return 0;+}++/* Append content to a file. */+static inline int th_append_file(const char *path, const char *content) {+ FILE *f = fopen(path, "a");+ if (!f) {+ return -1;+ }+ if (content && content[0]) {+ fputs(content, f);+ }+ fclose(f);+ return 0;+}++/* ── Directory creation ───────────────────────────────────────── */++/* Create a directory and all parents. Returns 0 on success. */+static inline int th_mkdir_p(const char *path) {+ return cbm_mkdir_p(path, 0755) ? 0 : -1;+}++/* ── Recursive directory removal ──────────────────────────────── */++/* Remove a file or directory tree recursively. Cross-platform rm -rf. */+static inline int th_rmtree(const char *path) {+ struct stat st;+ if (stat(path, &st) != 0) {+ return 0; /* doesn't exist — success */+ }++ if (!S_ISDIR(st.st_mode)) {+ return cbm_unlink(path);+ }++ /* Directory — recurse into children */+ cbm_dir_t *d = cbm_opendir(path);+ if (!d) {+ return -1;+ }++ cbm_dirent_t *entry;+ int rc = 0;+ while ((entry = cbm_readdir(d)) != NULL) {+ if (strcmp(entry->name, ".") == 0 || strcmp(entry->name, "..") == 0) {+ continue;+ }+ char child[1024];+ snprintf(child, sizeof(child), "%s/%s", path, entry->name);+ if (entry->is_dir) {+ if (th_rmtree(child) != 0) {+ rc = -1;+ }+ } else {+ if (cbm_unlink(child) != 0) {+ rc = -1;+ }+ }+ }+ cbm_closedir(d);+ cbm_rmdir(path);+ return rc;+}++/* ── Temp directory creation ──────────────────────────────────── */++/* Create a temporary directory. Returns static buffer with path.+ * Pattern: prefix is used as part of the dirname. */+static inline char *th_mktempdir(const char *prefix) {+ static char buf[256];+#ifdef _WIN32+ const char *tmp = getenv("TEMP");+ if (!tmp) tmp = getenv("TMP");+ if (!tmp) tmp = "C:\\Temp";+ snprintf(buf, sizeof(buf), "%s\\%s_XXXXXX", tmp, prefix);+#else+ snprintf(buf, sizeof(buf), "/tmp/%s_XXXXXX", prefix);+#endif+ if (!cbm_mkdtemp(buf)) {+ return NULL;+ }+ return buf;+}++/* ── File permissions (no-op on Windows) ──────────────────────── */++/* Make a file executable. On Windows this is a no-op (all files are+ * "executable" if they have the right extension). */+static inline void th_make_executable(const char *path) {+#ifndef _WIN32+ chmod(path, 0755);+#else+ (void)path;+#endif+}++/* ── Cleanup helper ───────────────────────────────────────────── */++/* Remove a temp directory tree. Safe to call with NULL. */+static inline void th_cleanup(const char *path) {+ if (path && path[0]) {+ th_rmtree(path);+ }+}++#endif /* TEST_HELPERS_H */