Skip to content

Inflection-0 Add .clang-format based on Apple WebKit style - #203

Open
nciric wants to merge 1 commit into
unicode-org:mainfrom
nciric:add-clang-format-config
Open

Inflection-0 Add .clang-format based on Apple WebKit style#203
nciric wants to merge 1 commit into
unicode-org:mainfrom
nciric:add-clang-format-config

Conversation

@nciric

@nciric nciric commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a root .clang-format configuration tailored to the formatting conventions of the Apple-donated codebase to establish a clear contribution policy.

This will make two things easier:

  1. Incoming contributions can focus on logic not style
  2. We can enable CI to auto-format all incoming code before merging

Rationale & Codebase Analysis

The configuration uses BasedOnStyle: WebKit (the canonical Apple C++ style preset in clang-format) with fine-tuned project settings based on an analysis of all 641 C/C++ files (59,203 lines) in the repository:

  • Column Limit (140): Over 96.4% of existing lines across the codebase are under 140 characters, minimizing unwanted line reflows while keeping lines bounded.
  • Indentation & Tabs: 0 tabs across 59k+ lines. Configured for 4-space indentation (IndentWidth: 4, UseTab: Never).
  • Bracing Convention:
    • Function definitions: Opening { on newline (used by 74.2% of .cpp functions and 87.6% of .hpp functions in src/inflection/).
    • Control flow (if, for, while): Attached { on same line (AfterControlStatement: Never).
    • else / catch: Attached (} else {, } catch (...) {).
  • Namespace Indentation: Set to None to prevent unneeded 4-space indentation across all namespace contents.
  • Pointers/References: Left-aligned (Type* ptr, Type& ref), matching over 87% of pointer declarations in the codebase.
  • Constructor Initializers: Comma-first style (BreakConstructorInitializers: BeforeComma).

@nciric
nciric requested a review from grhoten August 6, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant