---
# Tuned for a C codebase: snake_case, UPPER_CASE macros/enum constants,
# GNU-style formatting. C++-only groups (modernize, cppcoreguidelines, etc.)
# are left out on purpose.
Checks: >
  -*,
  bugprone-*,
  clang-analyzer-*,
  concurrency-*,
  misc-*,
  performance-*,
  portability-*,
  readability-*,
  cert-err34-c,
  cert-env33-c,
  cert-flp30-c,
  cert-msc30-c,
  cert-msc32-c,
  -bugprone-easily-swappable-parameters,
  -clang-analyzer-optin.performance.Padding,
  -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
  -misc-include-cleaner,
  -misc-no-recursion,
  -readability-function-size,
  -readability-identifier-length,
  -readability-magic-numbers,
  -misc-const-correctness,
  -readability-non-const-parameter,
  -readability-avoid-const-params-in-decls,
  -readability-function-cognitive-complexity,
  -readability-trailing-comma,
  -misc-use-internal-linkage

# Empty while you clean up existing findings. For CI, switch to
# 'bugprone-*,clang-analyzer-*' once the codebase is clean.
WarningsAsErrors: ''

# Report diagnostics from your own headers, not third-party ones.
# Adjust the directory names to match your layout.
HeaderFilterRegex: '.*/(core|nscore|include)/.*'

# Run from the repo root: the style file is .config/clang-format. Without it, -fix reformats with LLVM style.
FormatStyle: file:.config/clang-format

CheckOptions:
  # ---- Naming ----
  - key: readability-identifier-naming.FunctionCase
    value: lower_case
  - key: readability-identifier-naming.VariableCase
    value: lower_case
  - key: readability-identifier-naming.ParameterCase
    value: lower_case
  - key: readability-identifier-naming.MemberCase
    value: lower_case
  - key: readability-identifier-naming.StructCase
    value: lower_case
  - key: readability-identifier-naming.UnionCase
    value: lower_case
  - key: readability-identifier-naming.EnumCase
    value: lower_case
  - key: readability-identifier-naming.TypedefCase
    value: lower_case
  - key: readability-identifier-naming.EnumConstantCase
    value: UPPER_CASE
  - key: readability-identifier-naming.MacroDefinitionCase
    value: UPPER_CASE
  - key: readability-identifier-naming.VariableIgnoredRegexp
    value: '^_[a-z][a-z0-9_]*$'
  - key: readability-identifier-naming.ParameterIgnoredRegexp
    value: '^_[a-z][a-z0-9_]*$'
  - key: readability-identifier-naming.MemberIgnoredRegexp
    value: '^_[a-z][a-z0-9_]*$'
  - key: readability-identifier-naming.MacroDefinitionIgnoredRegexp
    value: '^test_.*$'
  - key: readability-identifier-naming.IgnoreMainLikeFunctions
    value: 'true'

  # ---- Readability ----
  # Force explicit comparisons: `ptr != NULL`, `ret != 0`, never `if (ptr)`
  # or `if (!ptr)` or `if (int_returning_call ())`.
  - key: readability-implicit-bool-conversion.AllowPointerConditions
    value: 'false'
  - key: readability-implicit-bool-conversion.AllowIntegerConditions
    value: 'false'
  - key: readability-function-cognitive-complexity.Threshold
    value: '25'
  - key: readability-function-cognitive-complexity.IgnoreMacros
    value: 'true'
  - key: readability-inconsistent-declaration-parameter-name.Strict
    value: 'false'

  # ---- Cleanup rules (see .claude/skills/cleanup/SKILL.md) ----
  # Every fallible call's result is checked (outside tests): flag discarded
  # err_t results.
  - key: bugprone-unused-return-value.CheckedReturnTypes
    value: 'err_t'
  - key: bugprone-unused-return-value.AllowCastToVoid
    value: 'true'
  # All literal suffixes uppercase: 10U, 0x7CU, 1.0F, 5ULL.
  - key: readability-uppercase-literal-suffix.NewSuffixes
    value: ''
  # Braces on every if/else/loop body, even one-liners.
  - key: readability-braces-around-statements.ShortStatementLines
    value: '0'
  # No silent narrowing (u64 -> u32, i64 -> int, signed <-> unsigned).
  - key: bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion
    value: 'true'
  - key: bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion
    value: 'true'
...
