# .clang-tidy — C11 static analysis configuration (BLOCKING).
#
# ALL checks enabled. WarningsAsErrors: '*'.
# Check thresholds configured for idiomatic C11 (not C++).
#
# Disabled checks (with reasoning):
#
# C++ idiom checks (not applicable to C11):
#   - bugprone-multi-level-implicit-pointer-conversion: void* is implicit in C
#   - readability-implicit-bool-conversion: if(ptr), if(count) is idiomatic C
#
# LLVM analyzer false positives (no fix available):
#   - DeprecatedOrUnsafeBufferHandling: flags fprintf/snprintf, Annex K not
#     available on Linux/macOS (LLVM #64027)
#   - ArrayBound: taint analysis false positives on buf[fread_result] (LLVM #126884)
#
# Cosmetic checks whitelisted (no memory safety or performance impact):
#   - bugprone-easily-swappable-parameters: internal APIs with descriptive
#     param names; struct wrappers would add churn without safety benefit
#   - concurrency-mt-unsafe: only readdir() remains, which is safe with
#     per-directory-handle usage (each thread owns its DIR*)
#   - bugprone-command-processor: popen() required for git integration;
#     all inputs are validated internal strings, no injection risk

Checks: >
  -*,
  bugprone-*,
  cert-*,
  concurrency-*,
  darwin-*,
  linuxkernel-*,
  misc-*,
  performance-*,
  portability-*,
  readability-*,
  clang-analyzer-*,
  -bugprone-multi-level-implicit-pointer-conversion,
  -readability-implicit-bool-conversion,
  -bugprone-easily-swappable-parameters,
  -concurrency-mt-unsafe,
  -bugprone-command-processor,
  -cert-env33-c,
  -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
  -clang-analyzer-security.ArrayBound,

WarningsAsErrors: '*'

CheckOptions:
  readability-identifier-length.MinimumVariableNameLength: 1
  readability-identifier-length.MinimumParameterNameLength: 1
  readability-identifier-length.MinimumLoopCounterNameLength: 1
  readability-magic-numbers.IgnoredIntegerValues: ""
  readability-magic-numbers.IgnoredFloatingPointValues: ""
  bugprone-easily-swappable-parameters.MinimumLength: 3
  misc-include-cleaner.IgnoreHeaders: "sys/.*|mach/.*|dispatch/.*|_types/.*|Availability\\.h|secure/.*|_.*\\.h|zconf\\.h"
  readability-function-cognitive-complexity.Threshold: 25
  readability-function-size.StatementThreshold: 200
  readability-function-size.LineThreshold: 400

HeaderFilterRegex: '^(src|tests)/.*\.h$'

ExtraArgs:
  - '-std=c11'
  - '-Isrc'
  - '-Ivendored'
  - '-Ivendored/sqlite3'
  - '-Iinternal/cbm'
  - '-Iinternal/cbm/vendored/ts_runtime/include'
