Skip to content

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

Set cognitive complexity to industry default (25), tag 168 functions

Martin Vogel87c2e144c0ea
diff --git a/.clang-tidy b/.clang-tidy
index 92da175c0..d8119da24 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -76,9 +76,9 @@ CheckOptions:
readability-implicit-bool-conversion.AllowPointerConditions: true
readability-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"
- readability-function-cognitive-complexity.Threshold: 250
- readability-function-size.StatementThreshold: 400
- readability-function-size.LineThreshold: 800
+ readability-function-cognitive-complexity.Threshold: 25
+ readability-function-size.StatementThreshold: 200
+ readability-function-size.LineThreshold: 400
HeaderFilterRegex: '^(src|tests)/.*\.h$'
diff --git a/internal/cbm/ac.c b/internal/cbm/ac.c
index 61754cfa8..af20f1a37 100644
--- a/internal/cbm/ac.c
+++ b/internal/cbm/ac.c
@@ -72,6 +72,7 @@ static void queue_free(Queue *q) {
// alpha_size — alphabet size (256 if alpha_map is NULL)
//
// Returns a heap-allocated automaton. Caller must call cbm_ac_free().
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
CBMAutomaton *cbm_ac_build(const char **patterns, const int *lengths, int count,
const uint8_t *alpha_map, int alpha_size) {
if (count <= 0) {
diff --git a/internal/cbm/extract_calls.c b/internal/cbm/extract_calls.c
index 64ca974d4..49420d498 100644
--- a/internal/cbm/extract_calls.c
+++ b/internal/cbm/extract_calls.c
@@ -88,6 +88,7 @@ static bool lean_is_in_type_position(TSNode node) {
}
// Extract callee name from a call node
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static char *extract_callee_name(CBMArena *a, TSNode node, const char *source, CBMLanguage lang) {
// Lean 4: apply — name field is callee. Skip if in a type annotation position.
// Must be checked before the generic "name" field handler below.
@@ -278,6 +279,7 @@ static char *extract_callee_name(CBMArena *a, TSNode node, const char *source, C
// Walk AST for call nodes (iterative)
#define CALLS_STACK_CAP 512
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void walk_calls(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) {
TSNode stack[CALLS_STACK_CAP];
int top = 0;
@@ -385,6 +387,7 @@ void cbm_extract_calls(CBMExtractCtx *ctx) {
/* Extract all arguments from a call expression into call->args[].
* Captures expression text, resolved constants, keyword names, and
* dotted field chains (member_expression → "payload.info.url"). */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_call_args(CBMExtractCtx *ctx, TSNode args, CBMCall *call) {
uint32_t argc = ts_node_named_child_count(args);
int positional_idx = 0;
@@ -429,6 +432,7 @@ static void extract_call_args(CBMExtractCtx *ctx, TSNode args, CBMCall *call) {
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void handle_calls(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, WalkState *state) {
if (!spec->call_node_types || !spec->call_node_types[0]) {
return;
diff --git a/internal/cbm/extract_defs.c b/internal/cbm/extract_defs.c
index 0d50a2bdf..bb87e3303 100644
--- a/internal/cbm/extract_defs.c
+++ b/internal/cbm/extract_defs.c
@@ -40,6 +40,7 @@ static TSNode func_name_node(TSNode node) {
}
// Resolve the name node for a function, handling language-specific quirks
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
static TSNode resolve_func_name(TSNode node, CBMLanguage lang, const char *source) {
const char *kind = ts_node_type(node);
@@ -398,6 +399,7 @@ static bool is_js_exported(TSNode node) {
}
// Extract docstring from the node's leading comment
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char *extract_docstring(CBMArena *a, TSNode node, const char *source,
CBMLanguage lang) {
// Go: type_spec is inside type_declaration; comment is before type_declaration
@@ -498,6 +500,7 @@ static const char *decorator_method_name(const char *attr_text) {
* Pure AST approach: walks the decorator node's call children to find:
* 1. The function/attribute name → infer HTTP method
* 2. The first string argument → route path */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_route_from_decorators(CBMArena *a, TSNode func_node, const char *source,
const CBMLangSpec *spec, const char **out_path,
const char **out_method) {
@@ -583,6 +586,7 @@ static void extract_route_from_decorators(CBMArena *a, TSNode func_node, const c
}
// Extract decorator names from preceding decorator/annotation nodes
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char **extract_decorators(CBMArena *a, TSNode node, const char *source,
CBMLanguage lang, const CBMLangSpec *spec) {
if (!spec->decorator_node_types || !spec->decorator_node_types[0]) {
@@ -657,6 +661,7 @@ static const char **extract_decorators(CBMArena *a, TSNode node, const char *sou
}
// Extract base class names from a class node
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char **extract_base_classes(CBMArena *a, TSNode node, const char *source,
CBMLanguage lang) {
(void)lang;
@@ -841,6 +846,7 @@ static char *clean_type_name(CBMArena *a, const char *raw) {
// Extract param_names from a parameter list node.
// Returns NULL-terminated arena-allocated array.
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char **extract_param_names(CBMArena *a, TSNode params, const char *source,
CBMLanguage lang) {
(void)lang;
@@ -910,6 +916,7 @@ static const char **extract_param_names(CBMArena *a, TSNode params, const char *
// Extract return_types from a return type node.
// Parses Go-style multi-return (T1, T2) and single return types.
// Returns NULL-terminated arena-allocated array.
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char **extract_return_types(CBMArena *a, TSNode rt_node, const char *source,
CBMLanguage lang) {
(void)lang;
@@ -979,6 +986,7 @@ static const char **extract_return_types(CBMArena *a, TSNode rt_node, const char
// Extract param_types from a parameter list node.
// Returns NULL-terminated arena-allocated array.
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char **extract_param_types(CBMArena *a, TSNode params, const char *source,
CBMLanguage lang) {
if (ts_node_is_null(params)) {
@@ -1131,6 +1139,7 @@ static const char **extract_param_types(CBMArena *a, TSNode params, const char *
// --- Function definition extraction ---
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {
CBMArena *a = ctx->arena;
@@ -1272,6 +1281,7 @@ static void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
// --- Class definition extraction ---
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
static void extract_class_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {
CBMArena *a = ctx->arena;
const char *kind = ts_node_type(node);
@@ -1587,6 +1597,7 @@ static TSNode find_class_body(TSNode class_node, CBMLanguage lang) {
}
// Helper: try to extract method name from a node, with fallbacks
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static TSNode resolve_method_name(TSNode child, CBMLanguage lang) {
TSNode name_node = func_name_node(child);
if (!ts_node_is_null(name_node)) {
@@ -1661,6 +1672,7 @@ static TSNode resolve_method_name(TSNode child, CBMLanguage lang) {
}
// Push a single method definition
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void push_method_def(CBMExtractCtx *ctx, TSNode child, const char *class_qn,
const CBMLangSpec *spec, TSNode name_node) {
CBMArena *a = ctx->arena;
@@ -1741,6 +1753,7 @@ static void push_method_def(CBMExtractCtx *ctx, TSNode child, const char *class_
}
// Extract methods inside a class body
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_class_methods(CBMExtractCtx *ctx, TSNode class_node, const char *class_qn,
const CBMLangSpec *spec) {
TSNode body = find_class_body(class_node, ctx->language);
@@ -1872,6 +1885,7 @@ static void extract_rust_impl(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
// --- Elixir def/defp/defmodule ---
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_elixir_call(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {
CBMArena *a = ctx->arena;
@@ -2049,6 +2063,7 @@ static const char *extract_java_field_name(CBMArena *a, TSNode field, const char
/* ── Variable name extractors by language group ─────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_vars_mainstream(CBMExtractCtx *ctx, TSNode node, CBMArena *a,
const char *kind) {
(void)kind;
@@ -2153,6 +2168,7 @@ static void extract_vars_mainstream(CBMExtractCtx *ctx, TSNode node, CBMArena *a
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_vars_dynamic(CBMExtractCtx *ctx, TSNode node, CBMArena *a, const char *kind) {
switch (ctx->language) {
case CBM_LANG_PHP: {
@@ -2288,6 +2304,7 @@ static void extract_vars_dynamic(CBMExtractCtx *ctx, TSNode node, CBMArena *a, c
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_vars_jvm(CBMExtractCtx *ctx, TSNode node, CBMArena *a) {
switch (ctx->language) {
case CBM_LANG_SCALA: {
@@ -2344,6 +2361,7 @@ static void extract_vars_jvm(CBMExtractCtx *ctx, TSNode node, CBMArena *a) {
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_vars_config(CBMExtractCtx *ctx, TSNode node, CBMArena *a, const char *kind) {
switch (ctx->language) {
case CBM_LANG_YAML: {
@@ -2652,6 +2670,7 @@ static void extract_variables(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec
// Extract typed struct/class fields for cross-file LSP resolution (C/C++/CUDA/Go/Java/Rust etc.)
// Creates "Field" label definitions with return_type set to the field's type text.
// These are later collected by DefsToLSPDefs to build FieldDefs pipe-separated strings.
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_class_fields(CBMExtractCtx *ctx, TSNode class_node, const char *class_qn,
const CBMLangSpec *spec) {
if (!spec->field_node_types || !spec->field_node_types[0]) {
@@ -2819,6 +2838,7 @@ static void push_nested_class_nodes(TSNode body, const CBMLangSpec *spec, walk_d
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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];
diff --git a/internal/cbm/extract_imports.c b/internal/cbm/extract_imports.c
index 8ba0b0836..7293cf4cd 100644
--- a/internal/cbm/extract_imports.c
+++ b/internal/cbm/extract_imports.c
@@ -52,6 +52,7 @@ static const char *path_last(CBMArena *a, const char *path) {
// --- Go imports ---
// import_declaration -> import_spec_list -> import_spec -> (name, path)
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void parse_go_imports(CBMExtractCtx *ctx) {
CBMArena *a = ctx->arena;
@@ -133,6 +134,7 @@ static void parse_go_imports(CBMExtractCtx *ctx) {
// import_statement: import X, import X as Y
// import_from_statement: from X import Y, from X import Y as Z
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void parse_python_imports(CBMExtractCtx *ctx) {
CBMArena *a = ctx->arena;
@@ -244,6 +246,7 @@ 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(readability-function-cognitive-complexity)
static void walk_es_imports(CBMExtractCtx *ctx, TSNode node) {
CBMArena *a = ctx->arena;
const char *kind = ts_node_type(node);
@@ -424,6 +427,7 @@ static void parse_rust_imports(CBMExtractCtx *ctx) {
// --- C/C++ imports ---
// preproc_include -> path or string_literal
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void parse_c_imports(CBMExtractCtx *ctx) {
CBMArena *a = ctx->arena;
@@ -477,6 +481,7 @@ static void parse_c_imports(CBMExtractCtx *ctx) {
// --- Ruby imports ---
// call nodes: require("X"), require_relative("X")
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void parse_ruby_imports(CBMExtractCtx *ctx) {
CBMArena *a = ctx->arena;
@@ -606,6 +611,7 @@ static void parse_lua_imports(CBMExtractCtx *ctx) {
// --- Generic import parsing for languages with simple import_declaration ---
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void parse_generic_imports(CBMExtractCtx *ctx, const char *node_type) {
CBMArena *a = ctx->arena;
@@ -667,6 +673,7 @@ 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(readability-function-cognitive-complexity)
static 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_k8s.c b/internal/cbm/extract_k8s.c
index 26bbb693a..3f10e1cb3 100644
--- a/internal/cbm/extract_k8s.c
+++ b/internal/cbm/extract_k8s.c
@@ -91,6 +91,7 @@ static void emit_kustomize_sequence(CBMExtractCtx *ctx, TSNode seq_node, const c
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_kustomize(CBMExtractCtx *ctx) {
CBMArena *a = ctx->arena;
@@ -156,6 +157,7 @@ static void extract_kustomize(CBMExtractCtx *ctx) {
// Descend into the first block_mapping of a document and extract apiVersion,
// kind, and metadata.name. Returns void; fills kind_buf and meta_name_buf.
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_k8s_scalars(CBMExtractCtx *ctx, TSNode mapping, char *kind_buf, size_t kind_sz,
char *meta_name_buf, size_t meta_sz) {
CBMArena *a = ctx->arena;
diff --git a/internal/cbm/extract_semantic.c b/internal/cbm/extract_semantic.c
index 8244c4fb8..f61886048 100644
--- a/internal/cbm/extract_semantic.c
+++ b/internal/cbm/extract_semantic.c
@@ -13,6 +13,7 @@
// --- Throw/Raise extraction ---
// Process a single node for throw extraction (called from iterative walker).
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void process_throw_node(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {
const char *kind = ts_node_type(node);
@@ -105,6 +106,7 @@ static void walk_throws(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec
// --- Read/Write detection (iterative) ---
#define READWRITE_STACK_CAP 512
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void walk_readwrites(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) {
TSNode stack[READWRITE_STACK_CAP];
int top = 0;
@@ -159,6 +161,7 @@ void cbm_extract_semantic(CBMExtractCtx *ctx) {
// --- Unified handlers ---
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void handle_throws(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, WalkState *state) {
bool has_throws = spec->throw_node_types && spec->throw_node_types[0];
bool has_clause = spec->throws_clause_field && spec->throws_clause_field[0];
diff --git a/internal/cbm/extract_type_assigns.c b/internal/cbm/extract_type_assigns.c
index 0b0898306..8a3b808f7 100644
--- a/internal/cbm/extract_type_assigns.c
+++ b/internal/cbm/extract_type_assigns.c
@@ -10,6 +10,7 @@
// Extract class/type name from a constructor expression.
// e.g., new Foo() -> "Foo", Foo() -> "Foo" (if uppercase), Foo{} -> "Foo"
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char *extract_constructor_type(CBMArena *a, TSNode rhs, const char *source,
CBMLanguage lang) {
const char *kind = ts_node_type(rhs);
@@ -77,6 +78,7 @@ static const char *extract_constructor_type(CBMArena *a, TSNode rhs, const char
}
// Walk AST for assignment patterns where RHS is a constructor call.
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void walk_type_assigns(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {
const char *kind = ts_node_type(node);
@@ -189,6 +191,7 @@ void cbm_extract_type_assigns(CBMExtractCtx *ctx) {
// --- Unified handler ---
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void handle_type_assigns(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec,
WalkState *state) {
const char *kind = ts_node_type(node);
diff --git a/internal/cbm/extract_type_refs.c b/internal/cbm/extract_type_refs.c
index c26b59bb1..8d89bbec7 100644
--- a/internal/cbm/extract_type_refs.c
+++ b/internal/cbm/extract_type_refs.c
@@ -142,6 +142,7 @@ 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(readability-function-cognitive-complexity)
static void walk_body_type_refs(CBMExtractCtx *ctx, TSNode node, const char *func_qn) {
const char *kind = ts_node_type(node);
@@ -296,6 +297,7 @@ void cbm_extract_type_refs(CBMExtractCtx *ctx) {
// The cursor visits both, so this single handler replaces the old
// walk_type_refs + walk_body_type_refs split.
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void handle_type_refs(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, WalkState *state) {
if (!spec->function_node_types || !spec->function_node_types[0]) {
return;
diff --git a/internal/cbm/extract_unified.c b/internal/cbm/extract_unified.c
index d10bcf23d..69c6f070c 100644
--- a/internal/cbm/extract_unified.c
+++ b/internal/cbm/extract_unified.c
@@ -54,6 +54,7 @@ static void recompute_state(WalkState *state, const char *module_qn) {
}
// Compute function QN for scope tracking (mirrors cbm_enclosing_func_qn logic).
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char *compute_func_qn(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec,
WalkState *state) {
(void)spec;
@@ -251,6 +252,7 @@ static void handle_string_refs(CBMExtractCtx *ctx, TSNode node, const WalkState
/* Recursively walk YAML block_mapping_pair nodes, building dotted key paths.
* Emits string_refs with key_path for leaf values that are URLs or config values.
* Example: body.operational_info.post_url → "https://..." */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void walk_yaml_mapping(CBMExtractCtx *ctx, TSNode node, const char *prefix) {
uint32_t nc = ts_node_named_child_count(node);
for (uint32_t i = 0; i < nc; i++) {
@@ -386,6 +388,7 @@ static const char *infer_broker(const char *file_path, const char *source_key) {
/* Scan a YAML mapping for source+target key pairs.
* Collects all key-value pairs at this level and one level deep (for nested config:). */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void scan_mapping_for_bindings(CBMExtractCtx *ctx, TSNode mapping) {
const char *sources[8] = {NULL};
const char *source_keys[8] = {NULL};
@@ -504,6 +507,7 @@ static void scan_yaml_for_infra_bindings(CBMExtractCtx *ctx, TSNode node) {
* where one is a source key (topic, queue_name) and another is a
* target key (uri, push_endpoint). Handles nested blocks like
* push_config { push_endpoint = "..." }. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void scan_hcl_block_for_bindings(CBMExtractCtx *ctx, TSNode block) {
const char *sources[8] = {NULL};
const char *source_keys[8] = {NULL};
@@ -630,6 +634,7 @@ static void handle_yaml_nested(CBMExtractCtx *ctx, TSNode node) {
// --- Main unified cursor walk ---
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void cbm_extract_unified(CBMExtractCtx *ctx) {
const CBMLangSpec *spec = cbm_lang_spec(ctx->language);
if (!spec) {
diff --git a/internal/cbm/extract_usages.c b/internal/cbm/extract_usages.c
index 8ad3b6ff6..fb21c411c 100644
--- a/internal/cbm/extract_usages.c
+++ b/internal/cbm/extract_usages.c
@@ -72,6 +72,7 @@ static bool is_reference_node(TSNode node, CBMLanguage lang) {
// Iterative usage walker — explicit stack
#define USAGES_STACK_CAP 4096
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void walk_usages(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) {
TSNode stack[USAGES_STACK_CAP];
int top = 0;
diff --git a/internal/cbm/helpers.c b/internal/cbm/helpers.c
index 5ecfd9ca1..9af5f2e94 100644
--- a/internal/cbm/helpers.c
+++ b/internal/cbm/helpers.c
@@ -545,6 +545,7 @@ static const char *module_parents_matlab[] = {"source_file", NULL};
static const char *module_parents_form[] = {"source_file", NULL};
static const char *module_parents_magma[] = {"source_file", NULL};
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
bool cbm_is_module_level(TSNode node, CBMLanguage lang) {
TSNode parent = ts_node_parent(node);
if (ts_node_is_null(parent)) {
@@ -727,6 +728,7 @@ static size_t strip_ext_len(const char *s, size_t len) {
return len;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
char *cbm_fqn_compute(CBMArena *a, const char *project, const char *rel_path, const char *name) {
// Build: project.path1.path2.filename.name
// where rel_path = "path1/path2/filename.ext"
@@ -832,6 +834,7 @@ char *cbm_fqn_folder(CBMArena *a, const char *project, const char *rel_dir) {
/* ── String literal classifier ──────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static bool is_url_like(const char *s, int len) {
if (len < 3) {
return false;
diff --git a/internal/cbm/sqlite_writer.c b/internal/cbm/sqlite_writer.c
index 96d22c67c..876befeed 100644
--- a/internal/cbm/sqlite_writer.c
+++ b/internal/cbm/sqlite_writer.c
@@ -447,6 +447,7 @@ static void pb_add_cell(PageBuilder *pb, const uint8_t *cell, int cell_len) {
// - Lookup: X ≤ K0 → cell[0].left_child, K0 < X ≤ K1 → cell[1].left_child, etc.
// - Table keys: varint(rowid)
// - Index keys: varint(payload_len) + payload (full index record)
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static uint32_t pb_build_interior(PageBuilder *pb, bool is_index) {
if (!pb->leaves) {
return 0;
@@ -919,6 +920,7 @@ static uint32_t write_table_btree(FILE *fp, uint32_t *next_page, const uint8_t *
}
// Write leaf pages for an index, returns root page.
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static uint32_t write_index_btree(FILE *fp, uint32_t *next_page, uint8_t **cells, int *cell_lens,
int count) {
if (count == 0) {
diff --git a/src/cli/cli.c b/src/cli/cli.c
index a2da36d8e..ec59ea0b7 100644
--- a/src/cli/cli.c
+++ b/src/cli/cli.c
@@ -161,6 +161,7 @@ const char *cbm_detect_shell_rc(const char *home_dir) {
/* ── CLI binary detection ─────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
const char *cbm_find_cli(const char *name, const char *home_dir) {
static char buf[512];
if (!name || !name[0]) {
@@ -865,6 +866,7 @@ int cbm_remove_zed_mcp(const char *config_path) {
/* ── Agent detection ──────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
cbm_detected_agents_t cbm_detect_agents(const char *home_dir) {
cbm_detected_agents_t agents;
memset(&agents, 0, sizeof(agents));
@@ -1689,6 +1691,7 @@ int cbm_ensure_path(const char *bin_dir, const char *rc_file, bool dry_run) {
/* ── Tar.gz extraction ────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
unsigned char *cbm_extract_binary_from_targz(const unsigned char *data, int data_len,
int *out_len) {
if (!data || data_len <= 0 || !out_len) {
@@ -1811,6 +1814,7 @@ unsigned char *cbm_extract_binary_from_targz(const unsigned char *data, int data
/* ── Zip extraction (in-memory, replaces external unzip) ──────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
unsigned char *cbm_extract_binary_from_zip(const unsigned char *data, int data_len, int *out_len) {
if (!data || data_len <= 0 || !out_len) {
return NULL;
@@ -2444,6 +2448,7 @@ static const char *detect_arch(void) {
/* ── Agent config install/refresh (shared by install + update) ── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void cbm_install_agent_configs(const char *home, const char *binary_path, bool force,
bool dry_run) {
cbm_detected_agents_t agents = cbm_detect_agents(home);
@@ -2678,6 +2683,7 @@ static void cbm_install_agent_configs(const char *home, const char *binary_path,
/* ── Subcommand: install ──────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_cmd_install(int argc, char **argv) {
parse_auto_answer(argc, argv);
bool dry_run = false;
@@ -2784,6 +2790,7 @@ int cbm_cmd_install(int argc, char **argv) {
/* ── Subcommand: uninstall ────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_cmd_uninstall(int argc, char **argv) {
parse_auto_answer(argc, argv);
bool dry_run = false;
@@ -3018,6 +3025,7 @@ int cbm_cmd_uninstall(int argc, char **argv) {
/* ── Subcommand: update ───────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
int cbm_cmd_update(int argc, char **argv) {
parse_auto_answer(argc, argv);
diff --git a/src/cypher/cypher.c b/src/cypher/cypher.c
index 7a6137565..fbf44b078 100644
--- a/src/cypher/cypher.c
+++ b/src/cypher/cypher.c
@@ -154,6 +154,7 @@ static cbm_token_type_t keyword_lookup(const char *word) {
return TOK_IDENT;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_lex(const char *input, cbm_lex_result_t *out) {
memset(out, 0, sizeof(*out));
if (!input) {
@@ -499,6 +500,7 @@ static int parse_node(parser_t *p, cbm_node_pattern_t *out) {
}
/* Parse relationship: -[:TYPE|TYPE2*min..max]-> or <-[...]- */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int parse_rel(parser_t *p, cbm_rel_pattern_t *out) {
memset(out, 0, sizeof(*out));
out->min_hops = 1;
@@ -690,6 +692,7 @@ static const char *unsupported_clause_error(cbm_token_type_t type) {
static cbm_expr_t *parse_or_expr(parser_t *p);
/* Parse a single condition: var.prop OP value | var.prop IS [NOT] NULL | var.prop IN [...] */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static cbm_expr_t *parse_condition_expr(parser_t *p) {
/* Check for NOT prefix at condition level (e.g. NOT n.name CONTAINS "x") */
bool negated = match(p, TOK_NOT);
@@ -950,6 +953,7 @@ static const char *str_func_name(cbm_token_type_t t) {
}
/* Parse CASE WHEN ... THEN ... [ELSE ...] END */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static cbm_case_expr_t *parse_case_expr(parser_t *p) {
/* CASE already consumed */
cbm_case_expr_t *kase = calloc(1, sizeof(cbm_case_expr_t));
@@ -1004,6 +1008,7 @@ static cbm_case_expr_t *parse_case_expr(parser_t *p) {
}
/* Parse RETURN/WITH clause (shared logic) */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int parse_return_or_with(parser_t *p, cbm_return_clause_t **out, bool is_with) {
cbm_token_type_t tok = (int)is_with ? TOK_WITH : TOK_RETURN;
/* For WITH, we need to check it's standalone (not preceded by STARTS) */
@@ -1215,6 +1220,7 @@ static int parse_match_pattern(parser_t *p, cbm_pattern_t *pat) {
return 0;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_parse(const cbm_token_t *tokens, int token_count, cbm_parse_result_t *out) {
memset(out, 0, sizeof(*out));
parser_t p = {.tokens = tokens, .count = token_count, .pos = 0};
@@ -1753,6 +1759,7 @@ static void binding_set(binding_t *b, const char *var, const cbm_node_t *node) {
}
/* Evaluate a WHERE condition against a binding */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static bool eval_condition(const cbm_condition_t *c, binding_t *b) {
const char *actual;
@@ -2051,6 +2058,7 @@ static void scan_pattern_nodes(cbm_store_t *store, const char *project, int max_
/* ── Expand one pattern's relationships on a set of bindings ──── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
static void expand_pattern_rels(cbm_store_t *store, cbm_pattern_t *pat, binding_t **bindings,
int *bind_count, const int *bind_cap, const char **var_name,
bool is_optional) {
@@ -2195,6 +2203,7 @@ static void expand_pattern_rels(cbm_store_t *store, cbm_pattern_t *pat, binding_
/* ── Result postprocessing helpers ─────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void rb_apply_order_by(result_builder_t *rb, const cbm_return_clause_t *ret) {
if (!ret->order_by) {
return;
@@ -2346,6 +2355,272 @@ static const char *project_item(binding_t *b, cbm_return_item_t *item, char *fun
return raw;
}
+/* ── WITH clause: project bindings through aggregation or rename ── */
+
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
+static void execute_with_clause(cbm_query_t *q, binding_t **bindings_ptr, int *bind_count_ptr) {
+ cbm_return_clause_t *wc = q->with_clause;
+ if (!wc) {
+ return;
+ }
+ binding_t *bindings = *bindings_ptr;
+ int bind_count = *bind_count_ptr;
+
+ binding_t *vbindings = malloc((bind_count + 1) * sizeof(binding_t));
+ int vcount = 0;
+
+ /* Check if WITH has aggregation */
+ bool has_agg = false;
+ for (int i = 0; i < wc->count; i++) {
+ if (wc->items[i].func &&
+ (strcmp(wc->items[i].func, "COUNT") == 0 || strcmp(wc->items[i].func, "SUM") == 0 ||
+ strcmp(wc->items[i].func, "AVG") == 0 || strcmp(wc->items[i].func, "MIN") == 0 ||
+ strcmp(wc->items[i].func, "MAX") == 0 || strcmp(wc->items[i].func, "COLLECT") == 0)) {
+ has_agg = true;
+ break;
+ }
+ }
+
+ if (has_agg) {
+ typedef struct {
+ char group_key[1024];
+ const char **group_vals;
+ double *sums;
+ int *counts;
+ double *mins, *maxs;
+ } with_agg_t;
+ int agg_cap = 256;
+ with_agg_t *aggs = calloc(agg_cap, sizeof(with_agg_t));
+ int agg_cnt = 0;
+
+ for (int bi = 0; bi < bind_count; bi++) {
+ char key[1024] = "";
+ int kl = 0;
+ for (int ci = 0; ci < wc->count; ci++) {
+ if (wc->items[ci].func) {
+ continue;
+ }
+ const char *v = binding_get_virtual(&bindings[bi], wc->items[ci].variable,
+ wc->items[ci].property);
+ kl += snprintf(key + kl, sizeof(key) - (size_t)kl, "%s|", v);
+ if (kl >= (int)sizeof(key)) {
+ kl = (int)sizeof(key) - 1;
+ }
+ }
+ int found = -1;
+ for (int a = 0; a < agg_cnt; a++) {
+ if (strcmp(aggs[a].group_key, key) == 0) {
+ found = a;
+ break;
+ }
+ }
+ if (found < 0) {
+ if (agg_cnt >= agg_cap) {
+ agg_cap *= 2;
+ aggs = safe_realloc(aggs, agg_cap * sizeof(with_agg_t));
+ }
+ found = agg_cnt++;
+ snprintf(aggs[found].group_key, sizeof(aggs[found].group_key), "%s", key);
+ aggs[found].group_vals = malloc(wc->count * sizeof(const char *));
+ aggs[found].sums = calloc(wc->count, sizeof(double));
+ aggs[found].counts = calloc(wc->count, sizeof(int));
+ aggs[found].mins = malloc(wc->count * sizeof(double));
+ aggs[found].maxs = malloc(wc->count * sizeof(double));
+ for (int ci = 0; ci < wc->count; ci++) {
+ aggs[found].mins[ci] = 1e308;
+ aggs[found].maxs[ci] = -1e308;
+ }
+ for (int ci = 0; ci < wc->count; ci++) {
+ if (wc->items[ci].func) {
+ aggs[found].group_vals[ci] = heap_strdup("0");
+ continue;
+ }
+ const char *v = binding_get_virtual(&bindings[bi], wc->items[ci].variable,
+ wc->items[ci].property);
+ aggs[found].group_vals[ci] = heap_strdup(v);
+ }
+ }
+ for (int ci = 0; ci < wc->count; ci++) {
+ if (!wc->items[ci].func) {
+ continue;
+ }
+ aggs[found].counts[ci]++;
+ const char *raw = binding_get_virtual(&bindings[bi], wc->items[ci].variable,
+ wc->items[ci].property);
+ double dv = strtod(raw, NULL);
+ aggs[found].sums[ci] += dv;
+ if (dv < aggs[found].mins[ci]) {
+ aggs[found].mins[ci] = dv;
+ }
+ if (dv > aggs[found].maxs[ci]) {
+ aggs[found].maxs[ci] = dv;
+ }
+ }
+ }
+
+ vbindings = safe_realloc(vbindings, (agg_cnt + 1) * sizeof(binding_t));
+ for (int a = 0; a < agg_cnt; a++) {
+ binding_t vb = {0};
+ for (int ci = 0; ci < wc->count; ci++) {
+ const char *alias = wc->items[ci].alias;
+ char name_buf[256];
+ if (!alias) {
+ if (wc->items[ci].property) {
+ snprintf(name_buf, sizeof(name_buf), "%s.%s", wc->items[ci].variable,
+ wc->items[ci].property);
+ } else {
+ snprintf(name_buf, sizeof(name_buf), "%s", wc->items[ci].variable);
+ }
+ alias = name_buf;
+ }
+ char vbuf[64];
+ if (wc->items[ci].func) {
+ const char *f = wc->items[ci].func;
+ if (strcmp(f, "COUNT") == 0) {
+ snprintf(vbuf, sizeof(vbuf), "%d", aggs[a].counts[ci]);
+ } else if (strcmp(f, "SUM") == 0) {
+ snprintf(vbuf, sizeof(vbuf), "%.10g", aggs[a].sums[ci]);
+ } else if (strcmp(f, "AVG") == 0) {
+ snprintf(vbuf, sizeof(vbuf), "%.10g",
+ aggs[a].counts[ci] > 0 ? aggs[a].sums[ci] / aggs[a].counts[ci]
+ : 0);
+ } else if (strcmp(f, "MIN") == 0) {
+ snprintf(vbuf, sizeof(vbuf), "%.10g", aggs[a].mins[ci]);
+ } else if (strcmp(f, "MAX") == 0) {
+ snprintf(vbuf, sizeof(vbuf), "%.10g", aggs[a].maxs[ci]);
+ } else {
+ snprintf(vbuf, sizeof(vbuf), "%d", aggs[a].counts[ci]);
+ }
+ cbm_node_t vn = {.name = heap_strdup(vbuf),
+ .qualified_name = heap_strdup(alias)};
+ if (vb.var_count < 16) {
+ vb.var_names[vb.var_count] = vn.qualified_name;
+ vb.var_nodes[vb.var_count] = vn;
+ vb.var_count++;
+ }
+ } else {
+ cbm_node_t vn = {.name = heap_strdup(aggs[a].group_vals[ci]),
+ .qualified_name = heap_strdup(alias)};
+ if (vb.var_count < 16) {
+ vb.var_names[vb.var_count] = vn.qualified_name;
+ vb.var_nodes[vb.var_count] = vn;
+ vb.var_count++;
+ }
+ }
+ }
+ vbindings[vcount++] = vb;
+ }
+ for (int a = 0; a < agg_cnt; a++) {
+ for (int ci = 0; ci < wc->count; ci++) {
+ free((void *)aggs[a].group_vals[ci]);
+ }
+ free(aggs[a].group_vals);
+ free(aggs[a].sums);
+ free(aggs[a].counts);
+ free(aggs[a].mins);
+ free(aggs[a].maxs);
+ }
+ free(aggs);
+ } else {
+ for (int bi = 0; bi < bind_count; bi++) {
+ binding_t vb = {0};
+ for (int ci = 0; ci < wc->count; ci++) {
+ const char *alias = wc->items[ci].alias;
+ char name_buf[256];
+ if (!alias) {
+ if (wc->items[ci].property) {
+ snprintf(name_buf, sizeof(name_buf), "%s.%s", wc->items[ci].variable,
+ wc->items[ci].property);
+ } else {
+ snprintf(name_buf, sizeof(name_buf), "%s", wc->items[ci].variable);
+ }
+ alias = name_buf;
+ }
+ char func_buf[512];
+ const char *val =
+ project_item(&bindings[bi], &wc->items[ci], func_buf, sizeof(func_buf));
+ cbm_node_t vn = {.name = heap_strdup(val), .qualified_name = heap_strdup(alias)};
+ if (vb.var_count < 16) {
+ vb.var_names[vb.var_count] = vn.qualified_name;
+ vb.var_nodes[vb.var_count] = vn;
+ vb.var_count++;
+ }
+ }
+ vbindings[vcount++] = vb;
+ }
+ }
+
+ /* ORDER BY + SKIP + LIMIT */
+ if (wc->order_by) {
+ const char *ob = wc->order_by;
+ bool wdesc = (wc->order_dir && strcmp(wc->order_dir, "DESC") == 0) != 0;
+ for (int i2 = 0; i2 < vcount - 1; i2++) {
+ for (int j2 = 0; j2 < vcount - i2 - 1; j2++) {
+ const char *va = binding_get_virtual(&vbindings[j2], ob, NULL);
+ const char *vb2 = binding_get_virtual(&vbindings[j2 + 1], ob, NULL);
+ int cmp2;
+ char *ea = NULL;
+ char *eb = NULL;
+ double da = strtod(va, &ea);
+ double db = strtod(vb2, &eb);
+ if (ea != va && eb != vb2) {
+ cmp2 = (da > db) - (da < db);
+ } else {
+ cmp2 = strcmp(va, vb2);
+ }
+ if ((int)wdesc ? cmp2 < 0 : cmp2 > 0) {
+ binding_t tmp2 = vbindings[j2];
+ vbindings[j2] = vbindings[j2 + 1];
+ vbindings[j2 + 1] = tmp2;
+ }
+ }
+ }
+ }
+ if (wc->skip > 0 && wc->skip < vcount) {
+ for (int i2 = 0; i2 < wc->skip; i2++) {
+ binding_free(&vbindings[i2]);
+ }
+ memmove(vbindings, vbindings + wc->skip, (vcount - wc->skip) * sizeof(binding_t));
+ vcount -= wc->skip;
+ } else if (wc->skip >= vcount) {
+ for (int i2 = 0; i2 < vcount; i2++) {
+ binding_free(&vbindings[i2]);
+ }
+ vcount = 0;
+ }
+ if (wc->limit > 0 && vcount > wc->limit) {
+ for (int i2 = wc->limit; i2 < vcount; i2++) {
+ binding_free(&vbindings[i2]);
+ }
+ vcount = wc->limit;
+ }
+
+ /* Replace bindings with virtual */
+ for (int bi = 0; bi < bind_count; bi++) {
+ binding_free(&bindings[bi]);
+ }
+ free(bindings);
+
+ /* Post-WITH WHERE */
+ if (q->post_with_where) {
+ int kept = 0;
+ for (int i = 0; i < vcount; i++) {
+ if (eval_where(q->post_with_where, &vbindings[i])) {
+ if (kept != i) {
+ vbindings[kept] = vbindings[i];
+ }
+ kept++;
+ } else {
+ binding_free(&vbindings[i]);
+ }
+ }
+ vcount = kept;
+ }
+
+ *bindings_ptr = vbindings;
+ *bind_count_ptr = vcount;
+}
+
/* ── Execute a single query (no UNION recursion) ──────────────── */
// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
@@ -2488,269 +2763,7 @@ static int execute_single(cbm_store_t *store, cbm_query_t *q, const char *projec
}
/* Step 3b: WITH clause */
- if (q->with_clause) {
- cbm_return_clause_t *wc = q->with_clause;
- /* Project through WITH into virtual bindings */
- binding_t *vbindings = malloc((bind_count + 1) * sizeof(binding_t));
- int vcount = 0;
-
- /* Check if WITH has aggregation */
- bool has_agg = false;
- for (int i = 0; i < wc->count; i++) {
- if (wc->items[i].func &&
- (strcmp(wc->items[i].func, "COUNT") == 0 || strcmp(wc->items[i].func, "SUM") == 0 ||
- strcmp(wc->items[i].func, "AVG") == 0 || strcmp(wc->items[i].func, "MIN") == 0 ||
- strcmp(wc->items[i].func, "MAX") == 0 ||
- strcmp(wc->items[i].func, "COLLECT") == 0)) {
- has_agg = true;
- break;
- }
- }
-
- if (has_agg) {
- /* Group-by aggregation through WITH */
- typedef struct {
- char group_key[1024];
- const char **group_vals;
- double *sums;
- int *counts;
- double *mins, *maxs;
- } with_agg_t;
- int agg_cap = 256;
- with_agg_t *aggs = calloc(agg_cap, sizeof(with_agg_t));
- int agg_cnt = 0;
-
- for (int bi = 0; bi < bind_count; bi++) {
- char key[1024] = "";
- int kl = 0;
- for (int ci = 0; ci < wc->count; ci++) {
- if (wc->items[ci].func) {
- continue;
- }
- const char *v = binding_get_virtual(&bindings[bi], wc->items[ci].variable,
- wc->items[ci].property);
- kl += snprintf(key + kl, sizeof(key) - (size_t)kl, "%s|", v);
- if (kl >= (int)sizeof(key)) {
- kl = (int)sizeof(key) - 1;
- }
- }
- int found = -1;
- for (int a = 0; a < agg_cnt; a++) {
- if (strcmp(aggs[a].group_key, key) == 0) {
- found = a;
- break;
- }
- }
- if (found < 0) {
- if (agg_cnt >= agg_cap) {
- agg_cap *= 2;
- aggs = safe_realloc(aggs, agg_cap * sizeof(with_agg_t));
- }
- found = agg_cnt++;
- snprintf(aggs[found].group_key, sizeof(aggs[found].group_key), "%s", key);
- aggs[found].group_vals = malloc(wc->count * sizeof(const char *));
- aggs[found].sums = calloc(wc->count, sizeof(double));
- aggs[found].counts = calloc(wc->count, sizeof(int));
- aggs[found].mins = malloc(wc->count * sizeof(double));
- aggs[found].maxs = malloc(wc->count * sizeof(double));
- for (int ci = 0; ci < wc->count; ci++) {
- aggs[found].mins[ci] = 1e308;
- aggs[found].maxs[ci] = -1e308;
- }
- for (int ci = 0; ci < wc->count; ci++) {
- if (wc->items[ci].func) {
- aggs[found].group_vals[ci] = heap_strdup("0");
- continue;
- }
- const char *v = binding_get_virtual(&bindings[bi], wc->items[ci].variable,
- wc->items[ci].property);
- aggs[found].group_vals[ci] = heap_strdup(v);
- }
- }
- for (int ci = 0; ci < wc->count; ci++) {
- if (!wc->items[ci].func) {
- continue;
- }
- aggs[found].counts[ci]++;
- const char *raw = binding_get_virtual(&bindings[bi], wc->items[ci].variable,
- wc->items[ci].property);
- double dv = strtod(raw, NULL);
- aggs[found].sums[ci] += dv;
- if (dv < aggs[found].mins[ci]) {
- aggs[found].mins[ci] = dv;
- }
- if (dv > aggs[found].maxs[ci]) {
- aggs[found].maxs[ci] = dv;
- }
- }
- }
-
- /* Build virtual bindings from aggregated groups */
- vbindings = safe_realloc(vbindings, (agg_cnt + 1) * sizeof(binding_t));
- for (int a = 0; a < agg_cnt; a++) {
- binding_t vb = {0};
- for (int ci = 0; ci < wc->count; ci++) {
- const char *alias = wc->items[ci].alias;
- char name_buf[256];
- if (!alias) {
- if (wc->items[ci].property) {
- snprintf(name_buf, sizeof(name_buf), "%s.%s", wc->items[ci].variable,
- wc->items[ci].property);
- } else {
- snprintf(name_buf, sizeof(name_buf), "%s", wc->items[ci].variable);
- }
- alias = name_buf;
- }
- char vbuf[64];
- if (wc->items[ci].func) {
- const char *f = wc->items[ci].func;
- if (strcmp(f, "COUNT") == 0) {
- snprintf(vbuf, sizeof(vbuf), "%d", aggs[a].counts[ci]);
- } else if (strcmp(f, "SUM") == 0) {
- snprintf(vbuf, sizeof(vbuf), "%.10g", aggs[a].sums[ci]);
- } else if (strcmp(f, "AVG") == 0) {
- snprintf(vbuf, sizeof(vbuf), "%.10g",
- aggs[a].counts[ci] > 0 ? aggs[a].sums[ci] / aggs[a].counts[ci]
- : 0);
- } else if (strcmp(f, "MIN") == 0) {
- snprintf(vbuf, sizeof(vbuf), "%.10g", aggs[a].mins[ci]);
- } else if (strcmp(f, "MAX") == 0) {
- snprintf(vbuf, sizeof(vbuf), "%.10g", aggs[a].maxs[ci]);
- } else {
- snprintf(vbuf, sizeof(vbuf), "%d", aggs[a].counts[ci]);
- }
- /* Store as a "virtual node" with the value in name,
- * alias in qualified_name (freed by node_fields_free). */
- cbm_node_t vn = {.name = heap_strdup(vbuf),
- .qualified_name = heap_strdup(alias)};
- if (vb.var_count < 16) {
- vb.var_names[vb.var_count] = vn.qualified_name;
- vb.var_nodes[vb.var_count] = vn;
- vb.var_count++;
- }
- } else {
- cbm_node_t vn = {.name = heap_strdup(aggs[a].group_vals[ci]),
- .qualified_name = heap_strdup(alias)};
- if (vb.var_count < 16) {
- vb.var_names[vb.var_count] = vn.qualified_name;
- vb.var_nodes[vb.var_count] = vn;
- vb.var_count++;
- }
- }
- }
- vbindings[vcount++] = vb;
- }
- for (int a = 0; a < agg_cnt; a++) {
- for (int ci = 0; ci < wc->count; ci++) {
- free((void *)aggs[a].group_vals[ci]);
- }
- free(aggs[a].group_vals);
- free(aggs[a].sums);
- free(aggs[a].counts);
- free(aggs[a].mins);
- free(aggs[a].maxs);
- }
- free(aggs);
- } else {
- /* Non-aggregating WITH: simple projection rename */
- for (int bi = 0; bi < bind_count; bi++) {
- binding_t vb = {0};
- for (int ci = 0; ci < wc->count; ci++) {
- const char *alias = wc->items[ci].alias;
- char name_buf[256];
- if (!alias) {
- if (wc->items[ci].property) {
- snprintf(name_buf, sizeof(name_buf), "%s.%s", wc->items[ci].variable,
- wc->items[ci].property);
- } else {
- snprintf(name_buf, sizeof(name_buf), "%s", wc->items[ci].variable);
- }
- alias = name_buf;
- }
- char func_buf[512];
- const char *val =
- project_item(&bindings[bi], &wc->items[ci], func_buf, sizeof(func_buf));
- cbm_node_t vn = {.name = heap_strdup(val),
- .qualified_name = heap_strdup(alias)};
- if (vb.var_count < 16) {
- vb.var_names[vb.var_count] = vn.qualified_name;
- vb.var_nodes[vb.var_count] = vn;
- vb.var_count++;
- }
- }
- vbindings[vcount++] = vb;
- }
- }
-
- /* Apply WITH ORDER BY + SKIP + LIMIT on virtual bindings */
- if (wc->order_by) {
- const char *ob = wc->order_by;
- bool wdesc = (wc->order_dir && strcmp(wc->order_dir, "DESC") == 0) != 0;
- for (int i2 = 0; i2 < vcount - 1; i2++) {
- for (int j2 = 0; j2 < vcount - i2 - 1; j2++) {
- const char *va = binding_get_virtual(&vbindings[j2], ob, NULL);
- const char *vb2 = binding_get_virtual(&vbindings[j2 + 1], ob, NULL);
- int cmp2;
- char *ea = NULL;
- char *eb = NULL;
- double da = strtod(va, &ea);
- double db = strtod(vb2, &eb);
- if (ea != va && eb != vb2) {
- cmp2 = (da > db) - (da < db);
- } else {
- cmp2 = strcmp(va, vb2);
- }
- if ((int)wdesc ? cmp2 < 0 : cmp2 > 0) {
- binding_t tmp2 = vbindings[j2];
- vbindings[j2] = vbindings[j2 + 1];
- vbindings[j2 + 1] = tmp2;
- }
- }
- }
- }
- if (wc->skip > 0 && wc->skip < vcount) {
- for (int i2 = 0; i2 < wc->skip; i2++) {
- binding_free(&vbindings[i2]);
- }
- memmove(vbindings, vbindings + wc->skip, (vcount - wc->skip) * sizeof(binding_t));
- vcount -= wc->skip;
- } else if (wc->skip >= vcount) {
- for (int i2 = 0; i2 < vcount; i2++) {
- binding_free(&vbindings[i2]);
- }
- vcount = 0;
- }
- if (wc->limit > 0 && vcount > wc->limit) {
- for (int i2 = wc->limit; i2 < vcount; i2++) {
- binding_free(&vbindings[i2]);
- }
- vcount = wc->limit;
- }
-
- /* Replace bindings with virtual */
- for (int bi = 0; bi < bind_count; bi++) {
- binding_free(&bindings[bi]);
- }
- free(bindings);
- bindings = vbindings;
- bind_count = vcount;
-
- /* Apply post-WITH WHERE */
- if (q->post_with_where) {
- int kept = 0;
- for (int i = 0; i < bind_count; i++) {
- if (eval_where(q->post_with_where, &bindings[i])) {
- if (kept != i) {
- bindings[kept] = bindings[i];
- }
- kept++;
- } else {
- binding_free(&bindings[i]);
- }
- }
- bind_count = kept;
- }
- }
+ execute_with_clause(q, &bindings, &bind_count);
/* Step 4: Project results */
rb_init(rb);
diff --git a/src/discover/discover.c b/src/discover/discover.c
index 8cfcd34a0..07c566828 100644
--- a/src/discover/discover.c
+++ b/src/discover/discover.c
@@ -226,6 +226,7 @@ static void fl_add(file_list_t *fl, const char *abs_path, const char *rel_path,
/* ── Recursive walk ──────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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.c
index 76794449a..ff57e6a01 100644
--- a/src/discover/gitignore.c
+++ b/src/discover/gitignore.c
@@ -39,6 +39,7 @@ struct cbm_gitignore {
* Match a glob pattern against a string.
* Handles: * (non-slash), ** (any path), ? (single non-slash), [class]
*/
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static bool glob_match(const char *pat, const char *str) {
while (*pat && *str) {
if (pat[0] == '*' && pat[1] == '*') {
@@ -300,6 +301,7 @@ cbm_gitignore_t *cbm_gitignore_load(const char *path) {
return gi;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
bool cbm_gitignore_matches(const cbm_gitignore_t *gi, const char *rel_path, bool is_dir) {
if (!gi || !rel_path) {
return false;
diff --git a/src/discover/language.c b/src/discover/language.c
index 0efc28f65..09d566b0f 100644
--- a/src/discover/language.c
+++ b/src/discover/language.c
@@ -439,6 +439,7 @@ static bool str_contains(const char *haystack, const char *needle) {
return strstr(haystack, needle) != NULL;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
CBMLanguage cbm_disambiguate_m(const char *path) {
if (!path) {
return CBM_LANG_MATLAB;
diff --git a/src/foundation/yaml.c b/src/foundation/yaml.c
index f5b1ef783..f9170356e 100644
--- a/src/foundation/yaml.c
+++ b/src/foundation/yaml.c
@@ -117,6 +117,7 @@ typedef struct {
int indent;
} stack_entry_t;
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
cbm_yaml_node_t *cbm_yaml_parse(const char *text, int len) {
if (!text || len <= 0) {
return node_new(YAML_MAP);
diff --git a/src/graph_buffer/graph_buffer.c b/src/graph_buffer/graph_buffer.c
index b79110a57..3f330c6d7 100644
--- a/src/graph_buffer/graph_buffer.c
+++ b/src/graph_buffer/graph_buffer.c
@@ -264,6 +264,7 @@ void cbm_gbuf_set_next_id(cbm_gbuf_t *gb, int64_t next_id) {
/* ── Node operations ─────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int64_t cbm_gbuf_upsert_node(cbm_gbuf_t *gb, const char *label, const char *name,
const char *qualified_name, const char *file_path, int start_line,
int end_line, const char *properties_json) {
@@ -397,6 +398,7 @@ int cbm_gbuf_node_count(const cbm_gbuf_t *gb) {
return gb ? (int)cbm_ht_count(gb->node_by_qn) : 0;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_gbuf_delete_by_label(cbm_gbuf_t *gb, const char *label) {
if (!gb || !label) {
return -1;
@@ -494,6 +496,7 @@ int cbm_gbuf_delete_by_label(cbm_gbuf_t *gb, const char *label) {
return 0;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_gbuf_delete_by_file(cbm_gbuf_t *gb, const char *file_path) {
if (!gb || !file_path) {
return -1;
@@ -743,6 +746,7 @@ void cbm_gbuf_foreach_edge(const cbm_gbuf_t *gb, cbm_gbuf_edge_visitor_fn fn, vo
/* ── Edge operations ─────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int64_t cbm_gbuf_insert_edge(cbm_gbuf_t *gb, int64_t source_id, int64_t target_id, const char *type,
const char *properties_json) {
if (!gb || !type) {
@@ -867,6 +871,7 @@ int cbm_gbuf_edge_count_by_type(const cbm_gbuf_t *gb, const char *type) {
return arr ? arr->count : 0;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_gbuf_delete_edges_by_type(cbm_gbuf_t *gb, const char *type) {
if (!gb || !type) {
return -1;
@@ -930,6 +935,7 @@ static void free_remap_entry(const char *key, void *val, void *ud) {
free(val);
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_gbuf_merge(cbm_gbuf_t *dst, cbm_gbuf_t *src) {
if (!dst || !src) {
return -1;
@@ -1080,6 +1086,7 @@ static char *extract_url_path(const char *props) {
return cbm_strndup(key, (size_t)(end - key));
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_gbuf_dump_to_sqlite(cbm_gbuf_t *gb, const char *path) {
if (!gb || !path) {
return -1;
diff --git a/src/main.c b/src/main.c
index 28efdb7e7..0574afad5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -154,6 +154,7 @@ static void print_help(void) {
/* ── Main ───────────────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int main(int argc, char **argv) {
/* Parse arguments */
for (int i = 1; i < argc; i++) {
diff --git a/src/mcp/mcp.c b/src/mcp/mcp.c
index 58e1b0526..a11f974fe 100644
--- a/src/mcp/mcp.c
+++ b/src/mcp/mcp.c
@@ -697,6 +697,7 @@ static cbm_store_t *resolve_store(cbm_mcp_server_t *srv, const char *project) {
}
/* Build a helpful error listing available projects. Caller must free() result. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static char *build_project_list_error(const char *reason) {
char dir_path[1024];
cache_dir(dir_path, sizeof(dir_path));
@@ -762,6 +763,7 @@ static char *build_project_list_error(const char *reason) {
/* list_projects: scan cache directory for .db files.
* Each project is a single .db file — no central registry needed. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static char *handle_list_projects(cbm_mcp_server_t *srv, const char *args) {
(void)srv;
(void)args;
@@ -1219,6 +1221,7 @@ static char *handle_get_architecture(cbm_mcp_server_t *srv, const char *args) {
return result;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static char *handle_trace_call_path(cbm_mcp_server_t *srv, const char *args) {
char *func_name = cbm_mcp_get_string_arg(args, "function_name");
char *project = cbm_mcp_get_string_arg(args, "project");
@@ -1620,6 +1623,7 @@ static char *snippet_suggestions(const char *input, cbm_node_t *nodes, int count
}
/* Build an enriched snippet response for a resolved node. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static char *build_snippet_response(cbm_mcp_server_t *srv, cbm_node_t *node,
const char *match_method, bool include_neighbors,
cbm_node_t *alternatives, int alt_count) {
@@ -1954,6 +1958,7 @@ static void build_grep_cmd(char *cmd, size_t cmd_sz, bool use_regex, bool scoped
}
/* Phase 4: assemble JSON output from search results */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static char *assemble_search_output(search_result_t *sr, int sr_count, grep_match_t *raw,
int raw_count, int gm_count, int limit, int mode,
int context_lines, const char *root_path) {
@@ -2126,6 +2131,7 @@ static char *assemble_search_output(search_result_t *sr, int sr_count, grep_matc
return result;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
static char *handle_search_code(cbm_mcp_server_t *srv, const char *args) {
char *pattern = cbm_mcp_get_string_arg(args, "pattern");
char *project = cbm_mcp_get_string_arg(args, "project");
@@ -2595,6 +2601,7 @@ static char *handle_detect_changes(cbm_mcp_server_t *srv, const char *args) {
/* ── manage_adr ───────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static char *handle_manage_adr(cbm_mcp_server_t *srv, const char *args) {
char *project = cbm_mcp_get_string_arg(args, "project");
char *mode_str = cbm_mcp_get_string_arg(args, "mode");
@@ -3081,6 +3088,7 @@ char *cbm_mcp_server_handle(cbm_mcp_server_t *srv, const char *line) {
/* ── Event loop ───────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_mcp_server_run(cbm_mcp_server_t *srv, FILE *in, FILE *out) {
char *line = NULL;
size_t cap = 0;
diff --git a/src/pipeline/fqn.c b/src/pipeline/fqn.c
index 66bdd9bd4..2a322b38e 100644
--- a/src/pipeline/fqn.c
+++ b/src/pipeline/fqn.c
@@ -49,6 +49,7 @@ static char *join_segments(const char **segments, int count) {
/* ── Public API ──────────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
char *cbm_pipeline_fqn_compute(const char *project, const char *rel_path, const char *name) {
if (!project) {
return strdup("");
diff --git a/src/pipeline/httplink.c b/src/pipeline/httplink.c
index dee017d03..9fd5c094b 100644
--- a/src/pipeline/httplink.c
+++ b/src/pipeline/httplink.c
@@ -177,6 +177,7 @@ const char *cbm_confidence_band(double score) {
/* ── Path matching ─────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
const char *cbm_normalize_path(const char *input) {
static CBM_TLS char buf[1024];
if (!input || !*input) {
@@ -255,6 +256,7 @@ static void normalize_to_buf(const char *input, char *out, int out_size) {
out[len] = '\0';
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
bool cbm_paths_match(const char *call_path, const char *route_path) {
char norm_call[1024];
char norm_route[1024];
@@ -403,6 +405,7 @@ static double segment_jaccard(const char *norm_call, const char *norm_route) {
return (double)intersect / (double)max_len;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
double cbm_path_match_score(const char *call_path, const char *route_path) {
char norm_call[1024];
char norm_route[1024];
@@ -751,6 +754,7 @@ int cbm_extract_json_string_paths(const char *text, char **out, int max_out) {
/* ── Route extraction: Python ──────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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) {
@@ -832,6 +836,7 @@ int cbm_extract_python_routes(const char *name, const char *qn, const char **dec
/* ── Route extraction: Go gin/chi ──────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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) {
@@ -1097,6 +1102,7 @@ int cbm_extract_go_routes(const char *name, const char *qn, const char *source,
/* ── Route extraction: Java Spring ─────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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) {
@@ -1191,6 +1197,7 @@ int cbm_extract_java_routes(const char *name, const char *qn, const char **decor
/* ── Route extraction: Kotlin Ktor ─────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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) {
@@ -1289,6 +1296,7 @@ static bool is_express_receiver(const char *receiver) {
return false;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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) {
@@ -1472,6 +1480,7 @@ char *cbm_read_source_lines_disk(const char *root_dir, const char *rel_path, int
/* ── Read source lines from cached buffer ──────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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) {
diff --git a/src/pipeline/pass_calls.c b/src/pipeline/pass_calls.c
index 3acdf457e..819072bc5 100644
--- a/src/pipeline/pass_calls.c
+++ b/src/pipeline/pass_calls.c
@@ -66,6 +66,7 @@ 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. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,
const CBMFileResult *result, const char ***out_keys,
const char ***out_vals, int *out_count) {
@@ -161,6 +162,7 @@ static void free_import_map(const char **keys, const char **vals, int count) {
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int 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));
@@ -409,6 +411,7 @@ 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(readability-function-cognitive-complexity)
void 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.c
index 8a0ee26e6..b4842af96 100644
--- a/src/pipeline/pass_compile_commands.c
+++ b/src/pipeline/pass_compile_commands.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include "yyjson/yyjson.h"
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_split_command(const char *cmd, char **out, int max_out) {
if (!cmd || !out || max_out <= 0) {
return 0;
@@ -74,6 +75,7 @@ static char *resolve_path(const char *path, const char *directory) {
return strdup(path);
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
cbm_compile_flags_t *cbm_extract_flags(const char **args, int argc, const char *directory) {
cbm_compile_flags_t *f = calloc(1, sizeof(*f));
if (!f) {
@@ -145,6 +147,7 @@ void cbm_compile_flags_free(cbm_compile_flags_t *f) {
free(f);
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_parse_compile_commands(const char *json_data, const char *repo_path, char ***out_paths,
cbm_compile_flags_t ***out_flags) {
if (!json_data || !repo_path || !out_paths || !out_flags) {
diff --git a/src/pipeline/pass_configlink.c b/src/pipeline/pass_configlink.c
index 979653c60..1501cf248 100644
--- a/src/pipeline/pass_configlink.c
+++ b/src/pipeline/pass_configlink.c
@@ -206,6 +206,7 @@ static const char *path_basename(const char *path) {
return slash ? slash + 1 : path;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int collect_manifest_deps(const cbm_gbuf_node_t *const *vars, int var_count,
dep_entry_t *out, int max_out) {
int n = 0;
@@ -264,6 +265,7 @@ static int collect_manifest_deps(const cbm_gbuf_node_t *const *vars, int var_cou
return n;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int strategy_dep_imports(cbm_gbuf_t *gb) {
const cbm_gbuf_node_t **vars = NULL;
int var_count = 0;
@@ -351,6 +353,7 @@ 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(readability-function-cognitive-complexity)
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;
diff --git a/src/pipeline/pass_configures.c b/src/pipeline/pass_configures.c
index 7579b89fd..c711789cf 100644
--- a/src/pipeline/pass_configures.c
+++ b/src/pipeline/pass_configures.c
@@ -33,6 +33,7 @@ bool cbm_is_env_var_name(const char *s) {
return has_upper;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_normalize_config_key(const char *key, char *norm_out, size_t norm_sz) {
if (!key || !norm_out || norm_sz == 0) {
return 0;
diff --git a/src/pipeline/pass_definitions.c b/src/pipeline/pass_definitions.c
index ec51f09ed..ae3de2f37 100644
--- a/src/pipeline/pass_definitions.c
+++ b/src/pipeline/pass_definitions.c
@@ -65,6 +65,7 @@ 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(readability-function-cognitive-complexity)
static void append_json_string(char *buf, size_t bufsize, size_t *pos, const char *key,
const char *val) {
if (!val || !val[0]) {
@@ -195,6 +196,7 @@ static void build_def_props(char *buf, size_t bufsize, const CBMDefinition *def)
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int 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));
diff --git a/src/pipeline/pass_enrichment.c b/src/pipeline/pass_enrichment.c
index 90c5fd4b0..c9d6c2bd0 100644
--- a/src/pipeline/pass_enrichment.c
+++ b/src/pipeline/pass_enrichment.c
@@ -60,6 +60,7 @@ int cbm_split_camel_case(const char *s, char **out, int max_out) {
return count;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_tokenize_decorator(const char *dec, char **out, int max_out) {
if (!dec || !out || max_out <= 0) {
return 0;
@@ -273,6 +274,7 @@ static int cmp_str(const void *a, const void *b) {
return strcmp(*(const char **)a, *(const char **)b);
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_pipeline_pass_decorator_tags(cbm_gbuf_t *gbuf, const char *project) {
if (!gbuf || !project) {
return 0;
diff --git a/src/pipeline/pass_envscan.c b/src/pipeline/pass_envscan.c
index 904751011..ca808fffc 100644
--- a/src/pipeline/pass_envscan.c
+++ b/src/pipeline/pass_envscan.c
@@ -190,6 +190,7 @@ static file_type_t detect_file_type(const char *name) {
/* ── Line scanner ──────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int scan_line(const char *line, file_type_t ft, char *key_out, size_t key_sz, char *val_out,
size_t val_sz) {
cbm_regmatch_t m[5];
@@ -327,6 +328,7 @@ static int scan_line(const char *line, file_type_t ft, char *key_out, size_t key
/* ── Public API ────────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_scan_project_env_urls(const char *root_path, cbm_env_binding_t *out, int max_out) {
if (!root_path || !out || max_out <= 0) {
return 0;
diff --git a/src/pipeline/pass_gitdiff.c b/src/pipeline/pass_gitdiff.c
index a23fc0d23..a37b3fd20 100644
--- a/src/pipeline/pass_gitdiff.c
+++ b/src/pipeline/pass_gitdiff.c
@@ -35,6 +35,7 @@ void cbm_parse_range(const char *s, int *out_start, int *out_count) {
*out_count = (int)strtol(comma + 1, NULL, 10);
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_parse_name_status(const char *output, cbm_changed_file_t *out, int max_out) {
if (!output || !out || max_out <= 0) {
return 0;
@@ -109,6 +110,7 @@ int cbm_parse_name_status(const char *output, cbm_changed_file_t *out, int max_o
return count;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_parse_hunks(const char *output, cbm_changed_hunk_t *out, int max_out) {
if (!output || !out || max_out <= 0) {
return 0;
diff --git a/src/pipeline/pass_httplinks.c b/src/pipeline/pass_httplinks.c
index 269f11c90..56ce6c92c 100644
--- a/src/pipeline/pass_httplinks.c
+++ b/src/pipeline/pass_httplinks.c
@@ -334,6 +334,7 @@ static int discover_module_routes(const cbm_gbuf_node_t *mod, const cbm_pipeline
/* Resolve FastAPI include_router prefixes.
* Scans Python Module nodes for: app.include_router(var, prefix="/prefix")
* and from ... import var. Prepends prefix to routes from matching modules. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void resolve_fastapi_prefixes(cbm_pipeline_ctx_t *ctx, cbm_route_handler_t *routes,
int route_count) {
const cbm_gbuf_node_t **modules = NULL;
@@ -466,6 +467,7 @@ static void resolve_fastapi_prefixes(cbm_pipeline_ctx_t *ctx, cbm_route_handler_
}
/* Resolve Express app.use("/prefix", routerVar) prefixes. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void resolve_express_prefixes(cbm_pipeline_ctx_t *ctx, cbm_route_handler_t *routes,
int route_count) {
const cbm_gbuf_node_t **modules = NULL;
@@ -651,6 +653,7 @@ static void apply_prefix_to_func_routes(cbm_route_handler_t *routes, int route_c
/* Resolve Go gin cross-file Group() prefixes.
* Pattern: v1 := r.Group("/api"); RegisterRoutes(v1) */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void resolve_cross_file_group_prefixes(cbm_pipeline_ctx_t *ctx, cbm_route_handler_t *routes,
int route_count) {
/* Build routesByFunc index: funcQN → (start_index, count) in routes array */
@@ -863,6 +866,7 @@ static int create_registration_call_edges(cbm_pipeline_ctx_t *ctx, cbm_route_han
/* Insert Route nodes and HANDLES edges for discovered routes.
* Uses ResolvedHandlerQN if set (from createRegistrationCallEdges). */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int insert_route_nodes(cbm_pipeline_ctx_t *ctx, cbm_route_handler_t *routes,
int route_count) {
int count = 0;
@@ -989,6 +993,7 @@ static int insert_route_nodes(cbm_pipeline_ctx_t *ctx, cbm_route_handler_t *rout
/* ── Match and link ────────────────────────────────────────────── */
/* Match call sites to routes and create HTTP_CALLS/ASYNC_CALLS edges. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int match_and_link(cbm_pipeline_ctx_t *ctx, cbm_route_handler_t *routes, int route_count,
cbm_http_call_site_t *sites, int site_count) {
int link_count = 0;
@@ -1140,6 +1145,7 @@ typedef struct {
_Atomic int *cancelled;
} hl_site_ctx_t;
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void hl_site_worker(int worker_id, void *arg) {
hl_site_ctx_t *sc = arg;
hl_site_buf_t *buf = &sc->worker_bufs[worker_id];
@@ -1219,6 +1225,7 @@ static void hl_site_worker(int worker_id, void *arg) {
/* ── Main pass entry point ─────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_pipeline_pass_httplinks(cbm_pipeline_ctx_t *ctx) {
cbm_log_info("pass.start", "pass", "httplinks");
diff --git a/src/pipeline/pass_infrascan.c b/src/pipeline/pass_infrascan.c
index 58a2a43f2..5fd8945c3 100644
--- a/src/pipeline/pass_infrascan.c
+++ b/src/pipeline/pass_infrascan.c
@@ -297,6 +297,7 @@ bool cbm_is_secret_binding(const char *key, const char *value) {
/* ── Clean JSON brackets ────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void cbm_clean_json_brackets(const char *s, char *out, size_t out_sz) {
if (!s || !out || out_sz == 0) {
return;
@@ -466,6 +467,7 @@ static void df_parse_arg(const char *line, cbm_dockerfile_result_t *r) {
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void df_parse_directives(const char *line, cbm_dockerfile_result_t *r) {
/* WORKDIR */
if (strncasecmp(line, "WORKDIR", 7) == 0 && (line[7] == ' ' || line[7] == '\t')) {
@@ -568,6 +570,7 @@ int cbm_parse_dockerfile_source(const char *source, cbm_dockerfile_result_t *out
/* ── Dotenv parser ──────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_parse_dotenv_source(const char *source, cbm_dotenv_result_t *out) {
if (!source || !out) {
return -1;
@@ -779,6 +782,7 @@ static void shell_parse_docker(const char *line, cbm_shell_result_t *r) {
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_parse_shell_source(const char *source, cbm_shell_result_t *out) {
if (!source || !out) {
return -1;
@@ -933,6 +937,7 @@ static int tf_extract_ident(const char *p, const char *keyword, char *out, size_
return (int)(end - p + 1);
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_parse_terraform_source(const char *source, cbm_terraform_result_t *out) {
if (!source || !out) {
return -1;
diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.c
index dfc07a2ca..df6762623 100644
--- a/src/pipeline/pass_parallel.c
+++ b/src/pipeline/pass_parallel.c
@@ -80,6 +80,7 @@ static const char *itoa_log(int val) {
}
/* Append a JSON-escaped string value to buf at position *pos. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void append_json_string(char *buf, size_t bufsize, size_t *pos, const char *key,
const char *val) {
if (!val || !val[0]) {
@@ -361,6 +362,7 @@ typedef struct {
_Atomic int next_file_idx;
} extract_ctx_t;
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void extract_worker(int worker_id, void *ctx_ptr) {
extract_ctx_t *ec = ctx_ptr;
extract_worker_state_t *ws = &ec->workers[worker_id];
@@ -594,6 +596,7 @@ int cbm_parallel_extract(cbm_pipeline_ctx_t *ctx, cbm_file_info_t *files, int fi
/* ── Phase 3B: Serial Registry Build ─────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_build_registry_from_cache(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,
int file_count, CBMFileResult **result_cache) {
cbm_log_info("parallel.registry.start", "files", itoa_log(file_count));
@@ -710,6 +713,7 @@ typedef struct {
/* Append arg data as JSON to edge properties: ,"args":[{"i":0,"e":"x","v":"val"},...]
* Returns new position in buffer. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static size_t append_args_json(char *buf, size_t bufsize, size_t pos, const CBMCall *call) {
if (call->arg_count == 0 || pos >= bufsize - 20) {
return pos;
@@ -766,6 +770,7 @@ static size_t append_args_json(char *buf, size_t bufsize, size_t pos, const CBMC
/* Classify a resolved call by library identity and emit the appropriate edge.
* Extracted from resolve_worker to keep cognitive complexity under threshold. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void emit_service_edge(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *source,
const cbm_gbuf_node_t *target, const CBMCall *call,
const cbm_resolution_t *res, const char *module_qn,
@@ -944,6 +949,7 @@ static void emit_service_edge(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *source,
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
static void resolve_worker(int worker_id, void *ctx_ptr) {
resolve_ctx_t *rc = ctx_ptr;
resolve_worker_state_t *ws = &rc->workers[worker_id];
diff --git a/src/pipeline/pass_route_nodes.c b/src/pipeline/pass_route_nodes.c
index afb087646..9fd16b833 100644
--- a/src/pipeline/pass_route_nodes.c
+++ b/src/pipeline/pass_route_nodes.c
@@ -123,6 +123,7 @@ static const char *url_path(const char *url) {
/* Extract service name from Cloud Run URL hostname.
* "my-svc-ab12cd34ef-uc.a.run.app/path" → "my-svc" */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char *extract_service_name(const char *url, char *buf, int bufsz) {
if (!url) {
return NULL;
@@ -197,6 +198,7 @@ static const char *extract_service_name(const char *url, char *buf, int bufsz) {
}
/* Phase 2: Match infra Route URLs to handler Route nodes by URL path + service name. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void match_infra_routes(cbm_gbuf_t *gb) {
/* Collect infra Routes (from YAML) and handler Routes (from Python decorators) */
const cbm_gbuf_node_t **all_routes = NULL;
@@ -297,6 +299,7 @@ static void match_infra_routes(cbm_gbuf_t *gb) {
/* Phase 2a: Ensure all functions with route_path properties have Route+HANDLES edges.
* During incremental indexing, only changed files get Route nodes from extraction.
* This pass scans ALL Function/Method nodes and creates missing Route+HANDLES. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void ensure_decorator_routes(cbm_gbuf_t *gb) {
const char *labels[] = {"Function", "Method"};
int created = 0;
@@ -395,6 +398,7 @@ static void ensure_decorator_routes(cbm_gbuf_t *gb) {
* (from the registering file), derive the service directory, then find decorator
* Routes in that directory tree and create HANDLES from their handler Functions
* to the prefix Route. This bridges include_router → decorator → handler. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void connect_prefix_to_decorators(cbm_gbuf_t *gb) {
const cbm_gbuf_node_t **routes = NULL;
int route_count = 0;
@@ -535,6 +539,7 @@ static const char *find_args_in_props(const char *props) {
return p + 7; /* skip "args":[ , points to first { or ] */
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void create_data_flows(cbm_gbuf_t *gb) {
const cbm_gbuf_node_t **routes = NULL;
int route_count = 0;
diff --git a/src/pipeline/pass_semantic.c b/src/pipeline/pass_semantic.c
index d84e93740..5630d8908 100644
--- a/src/pipeline/pass_semantic.c
+++ b/src/pipeline/pass_semantic.c
@@ -202,6 +202,7 @@ static bool fp_ends_with(const char *fp, const char *suffix) {
return fplen >= sflen && strcmp(fp + fplen - sflen, suffix) == 0;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_pipeline_implements_go(cbm_pipeline_ctx_t *ctx) {
int edge_count = 0;
@@ -299,6 +300,7 @@ int cbm_pipeline_implements_go(cbm_pipeline_ctx_t *ctx) {
return edge_count;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int 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.c
index 540eba735..c7cc30cb1 100644
--- a/src/pipeline/pass_tests.c
+++ b/src/pipeline/pass_tests.c
@@ -134,6 +134,7 @@ bool cbm_is_test_func_name(const char *name) {
/* Try to derive the production file path from a test file path.
* Returns heap-allocated string or NULL. Caller must free(). */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static char *test_to_prod_path(const char *test_path) {
if (!test_path) {
return NULL;
@@ -208,6 +209,7 @@ static char *test_to_prod_path(const char *test_path) {
return NULL;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int 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;
diff --git a/src/pipeline/pass_usages.c b/src/pipeline/pass_usages.c
index c0573ca90..29d1cdebc 100644
--- a/src/pipeline/pass_usages.c
+++ b/src/pipeline/pass_usages.c
@@ -71,6 +71,7 @@ static bool is_checked_exception(const char *name) {
}
/* Build per-file import map from cached extraction result or graph buffer edges. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int build_import_map(cbm_pipeline_ctx_t *ctx, const char *rel_path,
const CBMFileResult *result, const char ***out_keys,
const char ***out_vals, int *out_count) {
@@ -180,6 +181,7 @@ static const cbm_gbuf_node_t *find_enclosing_node(cbm_pipeline_ctx_t *ctx, const
return node;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int 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));
diff --git a/src/pipeline/pipeline.c b/src/pipeline/pipeline.c
index 8a30bf792..69da7d41f 100644
--- a/src/pipeline/pipeline.c
+++ b/src/pipeline/pipeline.c
@@ -180,6 +180,7 @@ static void free_seen_dir_key(const char *key, void *val, void *ud) {
/* ── Pass 1: Structure ──────────────────────────────────────────── */
/* Create Project, Folder/Package, and File nodes in the graph buffer. */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int pass_structure(cbm_pipeline_t *p, const cbm_file_info_t *files, int file_count) {
cbm_log_info("pass.start", "pass", "structure", "files", itoa_buf(file_count));
@@ -325,6 +326,7 @@ static void *gh_compute_thread_fn(void *arg) {
/* Process infra bindings: topic→URL pairs from IaC configs.
* Creates Route nodes for endpoints and HANDLES edges linking
* topic Routes to endpoint Routes (bridging the gap). */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void cbm_pipeline_process_infra_bindings(cbm_gbuf_t *gbuf, const cbm_file_info_t *files,
CBMFileResult **result_cache, int file_count) {
int bindings = 0;
@@ -369,6 +371,7 @@ static void cbm_pipeline_process_infra_bindings(cbm_gbuf_t *gbuf, const cbm_file
}
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static void cbm_pipeline_extract_infra_routes(cbm_gbuf_t *gbuf, const cbm_file_info_t *files,
CBMFileResult **result_cache, int file_count) {
for (int i = 0; i < file_count; i++) {
@@ -402,6 +405,7 @@ static void cbm_pipeline_extract_infra_routes(cbm_gbuf_t *gbuf, const cbm_file_i
/* ── Pipeline run ────────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
int cbm_pipeline_run(cbm_pipeline_t *p) {
if (!p) {
return -1;
diff --git a/src/pipeline/pipeline_incremental.c b/src/pipeline/pipeline_incremental.c
index 3b9e3e772..479b1c74a 100644
--- a/src/pipeline/pipeline_incremental.c
+++ b/src/pipeline/pipeline_incremental.c
@@ -170,6 +170,7 @@ static void registry_visitor(const cbm_gbuf_node_t *node, void *userdata) {
/* ── Incremental pipeline entry point ────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_pipeline_run_incremental(cbm_pipeline_t *p, const char *db_path, cbm_file_info_t *files,
int file_count) {
struct timespec t0;
diff --git a/src/pipeline/registry.c b/src/pipeline/registry.c
index 68c2dad68..3927bc71a 100644
--- a/src/pipeline/registry.c
+++ b/src/pipeline/registry.c
@@ -342,6 +342,7 @@ static cbm_resolution_t resolve_same_module(const cbm_registry_t *r, const char
}
/* Strategy 3+4: Name lookup + suffix match */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
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) {
diff --git a/src/store/store.c b/src/store/store.c
index 966bf1682..29c72bf37 100644
--- a/src/store/store.c
+++ b/src/store/store.c
@@ -1616,6 +1616,7 @@ int cbm_store_node_neighbor_names(cbm_store_t *s, int64_t node_id, int limit, ch
return 0;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_store_batch_count_degrees(cbm_store_t *s, const int64_t *node_ids, int id_count,
const char *edge_type, int *out_in, int *out_out) {
if (!s || !node_ids || id_count <= 0 || !out_in || !out_out) {
@@ -1933,6 +1934,7 @@ const char *cbm_strip_case_flag(const char *pattern) {
return buf;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_store_search(cbm_store_t *s, const cbm_search_params_t *params, cbm_search_output_t *out) {
memset(out, 0, sizeof(*out));
if (!s || !s->db) {
@@ -2144,6 +2146,7 @@ void cbm_store_search_free(cbm_search_output_t *out) {
/* ── BFS Traversal ──────────────────────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
int cbm_store_bfs(cbm_store_t *s, int64_t start_id, const char *direction, const char **edge_types,
int edge_type_count, int max_depth, int max_results, cbm_traverse_result_t *out) {
memset(out, 0, sizeof(*out));
@@ -2606,6 +2609,7 @@ bool cbm_is_test_file_path(const char *fp) {
}
/* File extension → language name mapping */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static const char *ext_to_lang(const char *ext) {
if (!ext) {
return NULL;
@@ -2835,6 +2839,7 @@ static int arch_entry_points(cbm_store_t *s, const char *project, cbm_architectu
return CBM_STORE_OK;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int arch_routes(cbm_store_t *s, const char *project, cbm_architecture_info_t *out) {
const char *sql = "SELECT name, properties, COALESCE(file_path, '') FROM nodes "
"WHERE project=?1 AND label='Route' "
@@ -2957,6 +2962,7 @@ static int arch_hotspots(cbm_store_t *s, const char *project, cbm_architecture_i
return CBM_STORE_OK;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int arch_boundaries(cbm_store_t *s, const char *project, cbm_cross_pkg_boundary_t **out_arr,
int *out_count) {
/* Build nodeID → package map */
@@ -3087,6 +3093,7 @@ static int arch_boundaries(cbm_store_t *s, const char *project, cbm_cross_pkg_bo
return CBM_STORE_OK;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int arch_packages(cbm_store_t *s, const char *project, cbm_architecture_info_t *out) {
/* Try Package nodes first */
const char *sql =
@@ -3222,6 +3229,7 @@ static void classify_layer(const char *pkg, int in, int out_deg, bool has_routes
(void)pkg;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int arch_layers(cbm_store_t *s, const char *project, cbm_architecture_info_t *out) {
/* Get boundaries for fan analysis */
cbm_cross_pkg_boundary_t *boundaries = NULL;
@@ -3385,6 +3393,7 @@ static int arch_layers(cbm_store_t *s, const char *project, cbm_architecture_inf
return CBM_STORE_OK;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_info_t *out) {
const char *sql = "SELECT file_path FROM nodes WHERE project=?1 AND label='File'";
sqlite3_stmt *stmt = NULL;
@@ -3654,6 +3663,7 @@ static int arch_file_tree(cbm_store_t *s, const char *project, cbm_architecture_
/* ── Louvain community detection ───────────────────────────────── */
+// NOLINTNEXTLINE(readability-function-cognitive-complexity,readability-function-size)
int cbm_louvain(const int64_t *nodes, int node_count, const cbm_louvain_edge_t *edges,
int edge_count, cbm_louvain_result_t **out, int *out_count) {
if (node_count <= 0) {
@@ -4055,6 +4065,7 @@ static bool is_canonical_section(const char *name) {
return false;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
cbm_adr_sections_t cbm_adr_parse_sections(const char *content) {
cbm_adr_sections_t result;
memset(&result, 0, sizeof(result));
@@ -4147,6 +4158,7 @@ cbm_adr_sections_t cbm_adr_parse_sections(const char *content) {
return result;
}
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
char *cbm_adr_render(const cbm_adr_sections_t *sections) {
if (!sections || sections->count == 0) {
return heap_strdup("");