# =============================================================================
# PulsimCore C++ Static Analysis Configuration
# =============================================================================
# Used by clang-tidy for code quality checks
# Run: make lint-cpp
# =============================================================================

# Header filter: only analyze project headers
HeaderFilterRegex: '(core|cli|api-grpc)/(include|src)/.*'

# Warning level
WarningsAsErrors: ''

# Checks to enable
Checks: >
  -*,
  bugprone-*,
  clang-analyzer-*,
  cppcoreguidelines-*,
  modernize-*,
  performance-*,
  readability-*,
  -bugprone-easily-swappable-parameters,
  -cppcoreguidelines-avoid-c-arrays,
  -cppcoreguidelines-avoid-magic-numbers,
  -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
  -cppcoreguidelines-pro-bounds-constant-array-index,
  -cppcoreguidelines-pro-bounds-pointer-arithmetic,
  -cppcoreguidelines-pro-type-reinterpret-cast,
  -cppcoreguidelines-pro-type-union-access,
  -modernize-use-trailing-return-type,
  -readability-braces-around-statements,
  -readability-function-cognitive-complexity,
  -readability-magic-numbers,
  -readability-identifier-length,

# Check-specific options
CheckOptions:
  # Naming conventions
  - key: readability-identifier-naming.ClassCase
    value: CamelCase
  - key: readability-identifier-naming.StructCase
    value: CamelCase
  - key: readability-identifier-naming.EnumCase
    value: CamelCase
  - key: readability-identifier-naming.EnumConstantCase
    value: CamelCase
  - key: readability-identifier-naming.FunctionCase
    value: lower_case
  - key: readability-identifier-naming.MethodCase
    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.PrivateMemberSuffix
    value: '_'
  - key: readability-identifier-naming.ProtectedMemberSuffix
    value: '_'
  - key: readability-identifier-naming.ConstantCase
    value: UPPER_CASE
  - key: readability-identifier-naming.GlobalConstantCase
    value: UPPER_CASE
  - key: readability-identifier-naming.StaticConstantCase
    value: UPPER_CASE
  - key: readability-identifier-naming.ConstexprVariableCase
    value: UPPER_CASE
  - key: readability-identifier-naming.NamespaceCase
    value: lower_case
  - key: readability-identifier-naming.TypeAliasCase
    value: CamelCase
  - key: readability-identifier-naming.TypedefCase
    value: CamelCase
  - key: readability-identifier-naming.TemplateParameterCase
    value: CamelCase
  - key: readability-identifier-naming.ConceptCase
    value: CamelCase

  # Function size limits
  - key: readability-function-size.LineThreshold
    value: '200'
  - key: readability-function-size.StatementThreshold
    value: '100'
  - key: readability-function-size.ParameterThreshold
    value: '8'

  # Modernize options
  - key: modernize-use-nullptr.NullMacros
    value: 'NULL'
  - key: modernize-loop-convert.MinConfidence
    value: 'reasonable'
  - key: modernize-pass-by-value.IncludeStyle
    value: 'llvm'
  - key: modernize-use-auto.MinTypeNameLength
    value: '5'
  - key: modernize-use-emplace.ContainersWithPushBack
    value: '::std::vector;::std::list;::std::deque'

  # Performance options
  - key: performance-move-const-arg.CheckTriviallyCopyableMove
    value: 'false'
  - key: performance-unnecessary-value-param.AllowedTypes
    value: ''

  # Clang analyzer options
  - key: clang-analyzer-core.CallAndMessage
    value: 'true'
  - key: clang-analyzer-core.DivideZero
    value: 'true'
  - key: clang-analyzer-core.NonNullParamChecker
    value: 'true'
  - key: clang-analyzer-core.NullDereference
    value: 'true'
  - key: clang-analyzer-deadcode.DeadStores
    value: 'true'

  # Bugprone options
  - key: bugprone-argument-comment.StrictMode
    value: 'false'
  - key: bugprone-assert-side-effect.AssertMacros
    value: 'assert,ASSERT'
  - key: bugprone-sizeof-expression.WarnOnSizeOfConstant
    value: 'true'
  - key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
    value: 'true'
  - key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
    value: 'true'

  # cppcoreguidelines options
  - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
    value: 'true'
  - key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
    value: 'true'
