style(k8s): apply clang-format to k8s and infra-pass source files

- Fix alignment violations in extract_k8s.c, pass_k8s.c, pass_infrascan.c
- Fix spacing in language.c filename table rows (kustomization.yml entry)
- Fix alignment in cbm.h CBMLanguage enum comments
- Fix pipeline.c empty-body brace style

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Shane McCarronandClaude Sonnet 4.6 committed 2026-03-21 09:29:22 -05:00
1 parent 5a663b9c84
commit e696fcdf80
6 files changed
+39 -33

No files matched your search

+2 -2
View File
@@ -75,8 +75,8 @@ typedef enum {
CBM_LANG_FORM,
CBM_LANG_MAGMA,
CBM_LANG_WOLFRAM,
CBM_LANG_KUSTOMIZE, // kustomization.yaml — Kubernetes overlay tool
CBM_LANG_K8S, // Generic Kubernetes manifest (apiVersion: detected)
CBM_LANG_KUSTOMIZE, // kustomization.yaml — Kubernetes overlay tool
CBM_LANG_K8S, // Generic Kubernetes manifest (apiVersion: detected)
CBM_LANG_COUNT
} CBMLanguage;
+11 -13
View File
@@ -66,8 +66,7 @@ static int is_kustomize_list_key(const char *key) {
// Walk a block_sequence node and emit one CBMImport per block_sequence_item
// scalar child, using key_name as the local_name.
static void emit_kustomize_sequence(CBMExtractCtx *ctx, TSNode seq_node,
const char *key_name) {
static void emit_kustomize_sequence(CBMExtractCtx *ctx, TSNode seq_node, const char *key_name) {
CBMArena *a = ctx->arena;
uint32_t n = ts_node_child_count(seq_node);
for (uint32_t i = 0; i < n; i++) {
@@ -84,7 +83,7 @@ static void emit_kustomize_sequence(CBMExtractCtx *ctx, TSNode seq_node,
continue;
}
CBMImport imp = {
.local_name = cbm_arena_strdup(a, key_name),
.local_name = cbm_arena_strdup(a, key_name),
.module_path = cbm_arena_strdup(a, scalar),
};
cbm_imports_push(&ctx->result->imports, a, imp);
@@ -157,11 +156,10 @@ 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.
static void extract_k8s_scalars(CBMExtractCtx *ctx, TSNode mapping,
char *kind_buf, size_t kind_sz,
char *meta_name_buf, size_t meta_sz) {
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;
kind_buf[0] = '\0';
kind_buf[0] = '\0';
meta_name_buf[0] = '\0';
uint32_t n = ts_node_child_count(mapping);
@@ -255,7 +253,7 @@ static void extract_k8s_manifest(CBMExtractCtx *ctx) {
continue;
}
char kind_buf[256] = {0};
char kind_buf[256] = {0};
char meta_name_buf[256] = {0};
extract_k8s_scalars(ctx, mapping, kind_buf, sizeof(kind_buf), meta_name_buf,
sizeof(meta_name_buf));
@@ -269,12 +267,12 @@ static void extract_k8s_manifest(CBMExtractCtx *ctx) {
snprintf(def_name, sizeof(def_name), "%s/%s", kind_buf, meta_name_buf);
CBMDefinition def = {0};
def.name = cbm_arena_strdup(a, def_name);
def.name = cbm_arena_strdup(a, def_name);
def.qualified_name = cbm_arena_sprintf(a, "%s.%s", ctx->module_qn, def_name);
def.label = "Resource";
def.file_path = ctx->rel_path;
def.start_line = ts_node_start_point(mapping).row + 1;
def.end_line = ts_node_end_point(mapping).row + 1;
def.label = "Resource";
def.file_path = ctx->rel_path;
def.start_line = ts_node_start_point(mapping).row + 1;
def.end_line = ts_node_end_point(mapping).row + 1;
cbm_defs_push(&ctx->result->defs, a, def);
break; // Only the first document per file
+10 -6
View File
@@ -269,12 +269,16 @@ typedef struct {
} filename_entry_t;
static const filename_entry_t FILENAME_TABLE[] = {
{"CMakeLists.txt", CBM_LANG_CMAKE}, {"Dockerfile", CBM_LANG_DOCKERFILE},
{"GNUmakefile", CBM_LANG_MAKEFILE}, {"Makefile", CBM_LANG_MAKEFILE},
{"makefile", CBM_LANG_MAKEFILE}, {"meson.build", CBM_LANG_MESON},
{"meson.options", CBM_LANG_MESON}, {"meson_options.txt", CBM_LANG_MESON},
{"CMakeLists.txt", CBM_LANG_CMAKE},
{"Dockerfile", CBM_LANG_DOCKERFILE},
{"GNUmakefile", CBM_LANG_MAKEFILE},
{"Makefile", CBM_LANG_MAKEFILE},
{"makefile", CBM_LANG_MAKEFILE},
{"meson.build", CBM_LANG_MESON},
{"meson.options", CBM_LANG_MESON},
{"meson_options.txt", CBM_LANG_MESON},
{"kustomization.yaml", CBM_LANG_KUSTOMIZE},
{"kustomization.yml", CBM_LANG_KUSTOMIZE},
{"kustomization.yml", CBM_LANG_KUSTOMIZE},
{".vimrc", CBM_LANG_VIMSCRIPT},
};
@@ -348,7 +352,7 @@ static const char *LANG_NAMES[CBM_LANG_COUNT] = {
[CBM_LANG_MAGMA] = "Magma",
[CBM_LANG_WOLFRAM] = "Wolfram",
[CBM_LANG_KUSTOMIZE] = "Kustomize",
[CBM_LANG_K8S] = "Kubernetes",
[CBM_LANG_K8S] = "Kubernetes",
};
/* ── Public API ──────────────────────────────────────────────────── */
+10 -5
View File
@@ -193,19 +193,24 @@ bool cbm_is_env_file(const char *name) {
}
bool cbm_is_kustomize_file(const char *name) {
if (!name) { return false; }
if (!name) {
return false;
}
char lower[256];
to_lower(name, lower, sizeof(lower));
return (strcmp(lower, "kustomization.yaml") == 0 ||
strcmp(lower, "kustomization.yml") == 0);
return (strcmp(lower, "kustomization.yaml") == 0 || 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; }
if (!name || !content || cbm_is_kustomize_file(name)) {
return false;
}
char buf[4097];
size_t n = strlen(content);
if (n > 4096) { n = 4096; }
if (n > 4096) {
n = 4096;
}
memcpy(buf, content, n);
buf[n] = '\0';
return ci_strstr(buf, "apiVersion:") != NULL;
+4 -6
View File
@@ -82,9 +82,8 @@ static void handle_kustomize(cbm_pipeline_ctx_t *ctx, const char *path, const ch
}
// 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\"}");
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);
if (mod_id <= 0) {
@@ -220,9 +219,8 @@ int cbm_pipeline_pass_k8s(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,
CBMLanguage lang = files[i].language;
const char *base = k8s_basename(rel);
CBMFileResult *cached = (ctx->result_cache && ctx->result_cache[i])
? ctx->result_cache[i]
: NULL;
CBMFileResult *cached =
(ctx->result_cache && ctx->result_cache[i]) ? ctx->result_cache[i] : NULL;
if (cbm_is_kustomize_file(base)) {
handle_kustomize(ctx, path, rel, cached);
+2 -1
View File
@@ -520,7 +520,8 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {
cbm_clock_gettime(CLOCK_MONOTONIC, &t);
rc = cbm_pipeline_pass_k8s(&ctx, files, file_count);
if (rc != 0) { /* log warning, continue */ }
if (rc != 0) { /* log warning, continue */
}
cbm_log_info("pass.timing", "pass", "k8s", "elapsed_ms", itoa_buf((int)elapsed_ms(t)));
if (check_cancel(p)) {
rc = -1;