Skip to content
CAI
Software that uses CAICheck a score

nicklockwood/SwiftFormat

64.3

Adequate · 27 September 2026

71.7k

lines of production code

Swift

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is SwiftFormat, a code formatter for the Swift programming language that provides a command-line tool, an Xcode source editor extension, and a Swift Package Manager plugin. It enforces consistent code style by applying a wide range of configurable formatting rules to Swift source files, package manifests, and Layout XML files. The system supports hierarchical configuration, linting, and integration into CI/CD workflows, while also including several snapshot projects like Euclid and Expression that serve as test cases and demonstration libraries for the formatter's capabilities.

How it got here

2016–2017 — Initial project scaffolding and tooling

12 changes.

This period established the foundational structure of the SwiftFormat project, including repository initialization, Xcode workspace configuration, and the release of the initial command-line tool. It introduced core features such as hierarchical configuration support, an Xcode editor extension with a companion preferences app, and Swift Package Manager integration.

2018–2019 — Snapshot library development and testing

17 changes.

This period focused on the initial release and expansion of several snapshot libraries, including Euclid for 3D geometry, Expression for parsing and evaluation, Layout for declarative UI, and Sprinter for string formatting. Significant effort was dedicated to establishing comprehensive test coverage, adding regression suites and performance benchmarks to ensure stability and measure execution speed. The work also included creating example applications to demonstrate usage and enhancing the Xcode extension to support these new tools.

2020–2026 — Plugin integration and infrastructure expansion

16 changes.

This period focused on integrating SwiftFormat into developer workflows via a new Swift Package Manager and Xcode command plugin, alongside automating release and Linux build processes. The project significantly expanded its test coverage and snapshot examples to include SwiftUI, concurrency, macros, and external libraries, while refactoring the internal rule architecture to a new API. Additionally, the team launched a dedicated documentation website and improved the Windows installer with code signing and bundled runtime support.

Features

Add Colors example app demonstrating expression-based color parsing

The Colors example application has been added to the Snapshots/Expression/Examples directory. This iOS app demonstrates the Expression library's capability to parse color strings, supporting named colors (e.g., 'red', 'blue'), hex formats (3, 4, 6, and 8-digit), and rgb/rgba functions. The implementation includes a UIColor extension that evaluates these expressions to set view colors, providing a concrete usage example for the library's expression evaluation features.

Snapshots/Expression/Examples/Colors · high confidence

Add Consumer project snapshot

Added a new snapshot containing the source code for the Consumer framework, including the public header, the core Consumer enum and matching logic, and the compiler extension that generates Swift parsing functions.

Snapshots/Consumer/Sources · high confidence

Add Consumer project snapshot with JSON and REPL examples

Added a new snapshot directory for the Consumer project containing example implementations. This includes a JSON parser example demonstrating interpreted, handwritten, and compiled parsing strategies, along with a REPL example showcasing expression evaluation and variable assignment.

Snapshots/Consumer/Examples · high confidence

Add Consumer project snapshot with Swift 5.0 support

A new snapshot project for the Consumer library has been added, establishing Swift 5.0 as the target language version and including standard project scaffolding such as a SwiftFormat configuration, an MIT license, and a Linux test entry point.

Snapshots/Consumer · high confidence

Add Expression and AnyExpression snapshot sources

Added the \Expression\ and \AnyExpression\ source files (version 0.12.12) to the \Snapshots/Expression/Sources\ directory. These files provide the core implementation for parsing and evaluating mathematical and logical expressions, including support for variables, operators, functions with specific arities, and custom symbol evaluators.

Snapshots/Expression/Sources · high confidence

Add SwiftFormat command plugin for Swift packages and Xcode projects

Developers can now run SwiftFormat directly via Swift Package Manager or Xcode using the new SwiftFormatPlugin. This plugin integrates the SwiftFormat tool into the build workflow, allowing users to format source code for all targets in a package or specific targets selected via the \--target\ argument. It supports both Swift package contexts and Xcode project contexts, ensuring consistent code formatting across different development environments.

Plugins/SwiftFormatPlugin · high confidence

Add SwiftUI snapshot projects

Added several new SwiftUI snapshot projects (Bookworm, CupcakeCorner, GuessTheFlag, Moonshot, WordScramble) to demonstrate various UI patterns and data handling, along with a .swiftformat configuration file for consistent code formatting.

Snapshots/SwiftUI · high confidence

Added Layout example application

The Snapshots/Expression/Examples/Layout directory now includes a complete iOS example application demonstrating the Expression layout library. This includes the AppDelegate, a ViewController for interactive layout editing, and a View extension (View+Layout.swift) that implements the core layout logic, supporting properties like left, top, width, and height with expression parsing and circular reference detection.

Snapshots/Expression/Examples/Layout · high confidence

Added Linux support and Swift toolchain configuration for Euclid and Expression snapshots

The Euclid and Expression snapshot projects now include configuration files and entry points to support testing on Linux. Specifically, \.swift-version\ files were added to specify Swift 4.2 for Euclid and Swift 4.0 for Expression, and \LinuxMain.swift\ files were introduced to register and run XCTest suites on Linux platforms. Additionally, \.swiftformat\ configuration files were added to standardize code formatting rules for these projects.

Snapshots/Euclid, Snapshots/Expression · high confidence

Added REPL snapshot example for expression evaluation

A new REPL (Read-Eval-Print Loop) example has been added to the Snapshots/Expression/Examples directory. This Swift script demonstrates how to parse and evaluate expressions interactively, supporting variable assignment, function definitions, and error handling while filtering out control characters to prevent input confusion.

Snapshots/Expression/Examples/REPL · high confidence

Added Swift 5.5 async/await and concurrency sample code

Added new snapshot files demonstrating Swift 5.5 concurrency features, including actors, async/await functions, async let, async sequences, effectful properties, and Sendable closures.

Snapshots/Async · high confidence

Added Swift macro examples and snapshot files

The Snapshots/Macros location now includes example source files demonstrating various Swift macros, including \stringify\, \addBlocker\, \URL\, \Observable\, \DictionaryStorage\, and \MyOptionSet\. These files serve as a snapshot or test harness to illustrate macro usage and behavior.

Snapshots/Macros · high confidence

Added example applications for Euclid and Expression libraries

New example projects have been added to demonstrate the usage of the Euclid and Expression libraries. The Euclid example showcases 3D scene creation and mesh operations using SceneKit, while the Expression examples include a Calculator app for evaluating mathematical expressions and a Benchmark app for comparing the performance of different expression evaluation methods.

Snapshots/Euclid/Example, Snapshots/Expression/Examples/Benchmark, Snapshots/Expression/Examples/Calculator · high confidence

Initial UI layout for SwiftFormat for Xcode preferences

The main storyboard for the SwiftFormat for Xcode application has been created, establishing the foundational user interface for the preferences window. This includes the standard macOS application menu structure (File, Edit, Services) with specific actions for opening, saving, and resetting configuration files, as well as the core window layout required for the extension's settings.

EditorExtension/Application/Base.lproj · high confidence

Initial Xcode workspace configuration added

The project now includes the standard Xcode workspace structure, adding the workspace data file, workspace settings (with Previews and autocreate contexts disabled), and IDE workspace checks. This establishes the foundational build environment for the SwiftFormat project.

SwiftFormat.xcodeproj/project.xcworkspace · high confidence

Initial project scaffolding and configuration

The repository is initialized with essential configuration files, including \.swiftformat\ to define default formatting rules and options, \.gitignore\ and \.dockerignore\ to manage build artifacts, and a \Dockerfile\ for containerized builds. Documentation and contribution guidelines are added via \README.md\, \CONTRING.md\, and \CLAUDE.md\, alongside a \Rakefile\ for site generation and a \.pre-commit-hooks.yaml\ file to integrate the tool into pre-commit workflows.

(repo-wide) · high confidence

Initial release of the Euclid 3D geometry library

This change introduces the core source files for the Euclid library, adding foundational 3D geometry types such as Vector, Bounds, Plane, Path, Polygon, and Mesh. It includes Boolean operations for meshes (union, subtract, intersect, xor, stencil), path manipulation utilities, and platform-specific integrations for CoreGraphics, CoreText, and SceneKit to enable text extrusion and 3D rendering.

Snapshots/Euclid/Sources · high confidence

Initial release of the Layout declarative UI framework and Xcode extension

This change introduces the Layout framework, a declarative UI system for iOS and macOS that allows developers to define view hierarchies using XML files. The diff adds the core library implementation, including XML parsing, expression evaluation, and layout node management, along with a debug console for displaying errors in a red box overlay. It also includes an Xcode Source Editor extension that enables formatting of Layout XML files directly within the IDE, and a benchmarking application to compare Layout performance against standard Auto Layout.

Snapshots/Layout · high confidence

Initial release of the SwiftFormat command-line tool

This change introduces the \CommandLineTool\ entry point (\main.swift\), establishing the executable interface for SwiftFormat. It configures platform-specific imports (Darwin, Glibc, Musl, UCRT), sets up a thread-safe print queue for output, and routes informational, success, error, and warning messages to stderr with optional ANSI color coding, while sending formatted content to stdout. The tool determines the current working directory, executes the CLI logic, and exits with the appropriate status code.

CommandLineTool · high confidence

Introduce hierarchical configuration file support

The tool now supports hierarchical \.swiftformat\ configuration files, allowing users to define options in parent directories that are inherited and merged by child directories. This change introduces logic to parse comma-delimited config paths, expand file paths relative to the current directory, and merge arguments from multiple configuration sources, enabling more granular and reusable formatting rules across a project structure.

Sources · high confidence

Introduce standalone SwiftFormat for Xcode configuration app

A new companion application for the Xcode Source Editor extension has been added, providing a graphical interface to manage formatting rules and options. The app allows users to enable or disable specific formatting rules, adjust rule-specific options via checkboxes, dropdowns, and text fields, and select the target Swift version. It supports importing and exporting \.swiftformat\ configuration files, includes a search bar to filter rules, and displays dynamic setup instructions in the About window based on the macOS version (System Preferences vs. System Settings). The application shares configuration state with the extension via an app group container.

EditorExtension/Application · high confidence

Launch of new SwiftFormat documentation website

The project now includes a dedicated Jekyll-based documentation site that automatically generates pages from the repository's README and Rules documentation. This site features a responsive layout with a sidebar table of contents, support for dark mode, and a specific page for prerelease rules sourced from the develop branch. It also includes a footer displaying the current version and last update date, along with improved heading link support for easier navigation.

site · high confidence

New release automation and Linux build scripts

Added \prepare\_release.sh\ to automate version updates across project files, run tests, archive binaries, and re-format the codebase before release. Introduced \build-linux-release.sh\ to compile SwiftFormat for Linux (x86\_64 and AArch64) with a larger stack size, and \spm-artifact-bundle.sh\ to package macOS and Linux binaries into a distributable artifact bundle. Also added \get-version.sh\ to extract the current version and \test\_rule.sh\ to test individual formatting rules on Linux.

Scripts · high confidence

Sprinter library added to project

The Sprinter library (version 0.2.1) has been added to the project, providing a \FormatString\ type for parsing and formatting format strings. This includes support for various flags, field widths, length modifiers, and conversion specifiers.

Snapshots/Sprinter/Sources · high confidence

Xcode extension now supports linting and Swift Package Manifest files

The Xcode editor extension has been updated to include a new 'Lint File' command, allowing users to check code for style violations without modifying it. Additionally, support has been added for Swift Package manifest files (e.g., Package.swift), enabling formatting and linting operations on these files alongside standard Swift source code.

EditorExtension/Extension · high confidence

Architecture

Migrate rules to DeclarationV2 API and restructure rule files

The rule implementation files in Sources/Rules have been restructured so that each rule is defined in its own separate file, and the internal parsing logic has been migrated to the new DeclarationV2 API (later renamed to Declaration). This refactoring improves code organization and provides a more robust foundation for rule implementations, though it does not change the formatting behavior for users.

Sources/Rules · high confidence

Behavioural changes

Added Xcode schemes for performance, regression, and editor extension targets

New Xcode scheme files have been added to configure build and test actions for specific targets: Performance Tests, Regression Tests, the Command Line Tool, the Editor Extension, the Framework, and the main SwiftFormat for Xcode app. These schemes enable parallelized builds, configure release-mode execution for performance and regression tests, and set up launch profiles for the Xcode source editor extension and command-line tool, supporting faster CI feedback and dedicated testing workflows.

SwiftFormat.xcodeproj/xcshareddata/xcschemes · high confidence

Enhanced rule searchability and legacy option handling in the Xcode extension

The Xcode extension's settings store now allows users to find formatting rules by searching their help text and option names, in addition to rule names. Additionally, the OptionsStore has been updated to better handle legacy configuration values, ensuring that non-deprecated options correctly overwrite old settings during migration.

EditorExtension/Shared · high confidence

SwiftFormat for Xcode project structure and build configuration

The Xcode project file has been restructured to support the current codebase organization, including the addition of new source files such as \Inference.swift\, \Arguments.swift\, and various reporter implementations (\JSONReporter\, \XMLReporter\, \GithubActionsLogReporter\, \SARIFReporter\). The build configuration now explicitly embeds \XcodeKit.framework\ for the source editor extension and links against \SwiftFormat.framework\ for the main application and command-line tool targets. Test targets have been updated to include new test files like \VersionTests.swift\, \ParsingHelpersTests.swift\, and \DeclarationV2Tests.swift\, reflecting the migration to the \Declaration\ API and the addition of new formatting rules and inference logic.

SwiftFormat.xcodeproj · high confidence

Windows installer now includes code signing and Swift runtime

The Windows installer has been updated to use WiX 4.0.5 and now includes the Swift runtime merge modules, ensuring the tool works out-of-the-box without requiring a separate Swift installation. Additionally, the build process now supports code-signing the installer components, improving trust and security for Windows users.

Platforms · high confidence

Test coverage

Add regression tests for SwiftFormat option overrides; Add test coverage for formatting rules; Added Sprinter snapshot project scaffolding; Added benchmark and regression test suites for Expression evaluation; Added comprehensive test suite for command-line argument parsing and code organization; Added performance benchmarking suite for SwiftFormat; Added regression and performance test suites for Sprinter; Added regression test suite for Euclid geometry primitives; Added regression test suite for Expression parsing and evaluation; Added regression test suite for SwiftFormat; Added snapshot tests for issues 1061, 1129, 1183, 1184, 1201, 1202, 1205, 1212, 1254, 1259, 1269, 1319, 1491, 1582, 1644, 406, 411, 637, 645, 678, 681, 682, 687, 697, 780, and 794; Added test harness for Swift package command plugin; Added test suite for Consumer parser library; Updated performance test baselines for new hardware.

Dependencies

Add Swift Package Manager support and Ruby build dependencies

The project now supports installation via Swift Package Manager, introducing a root Package.swift that defines the SwiftFormat library, command-line tool, and a new SwiftFormatPlugin for Xcode integration. Additionally, a Gemfile and Gemfile.lock have been added to manage Ruby dependencies, specifically pinning Jekyll (\~\> 4.4) and Rake (\~\> 13.0) for build and documentation tasks.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.

Score

  • CAI 46 → 64 (+18.4)
  • Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 100 → 73 (-26.6)
  • Architecture 69 → 94 (+25.1)
  • Maturity 57 → 65 (+7.9)
  • Readiness 32 → 71 (+38.6)
  • Security 49 → 58 (+9.0)
  • Event-Driven 75 (new)

Resolved (52)

  • Dimension evaluation failed
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • …and 32 more

New (5589)

  • AnyExpression.init (cognitive 150) (Snapshots/Expression/Sources/AnyExpression.swift)
  • AnyExpression.init (cyclomatic 109) (Snapshots/Expression/Sources/AnyExpression.swift)
  • BSPNode.clip (cognitive 64) (Snapshots/Euclid/Sources/CSG.swift)
  • BSPNode.clip (cyclomatic 28) (Snapshots/Euclid/Sources/CSG.swift)
  • BSPNode.insert (cognitive 17) (Snapshots/Euclid/Sources/CSG.swift)
  • CGPath.paths (cognitive 32) (Snapshots/Euclid/Sources/CoreGraphics.swift)
  • CGPath.paths (cyclomatic 31) (Snapshots/Euclid/Sources/CoreGraphics.swift)
  • Change coupling: FormatFileCommand.swift ↔ FormatSelectionCommand.swift (EditorExtension/Extension/FormatFileCommand.swift)
  • Charset.ranges (cognitive 17) (Snapshots/Consumer/Sources/Consumer.swift)
  • ClassTooLong: FormatOptions (Sources/Options.swift)
  • ClassTooLong: FormatString (Snapshots/Sprinter/Sources/Sprinter.swift)
  • ClassTooLong: Inference (Sources/Inference.swift)
  • ClassTooLong: _Descriptors (Sources/OptionDescriptor.swift)
  • Collection.toString (cognitive 55) (Sources/Declaration.swift)
  • Collection.toString (cyclomatic 32) (Sources/Declaration.swift)
  • Declaration.declarationType (cognitive 68) (Sources/Declaration.swift)
  • Declaration.declarationType (cyclomatic 44) (Sources/Declaration.swift)
  • Duplicate method signature across related configuration types. Both FileOptions and Options expose an identical shouldSkipFile method. Since Options contains a FileOptions property, callers likely need to check one or the other, but the duplication suggests unclear ownership of this logic.
  • Duplicated block (10 lines × 2) (Snapshots/Euclid/Sources/SceneKit.swift)
  • Duplicated block (10 lines × 2) (Snapshots/Euclid/Sources/SceneKit.swift)
  • …and 5569 more

Changes since last survey

  • 46 commits — 30 feature/other, 16 fixes

By area

  • Sources/Rules — 22 commits
  • (root) — 10 commits
  • Tests/Rules — 3 commits
  • Sources/FormattingHelpers.swift — 2 commits
  • Sources/ParsingHelpers.swift — 2 commits
  • (repo) — 1 commit
  • Scripts/build-linux-release.sh — 1 commit
  • Sources/Arguments.swift — 1 commit
  • Sources/CommandLine.swift — 1 commit
  • Sources/DeclarationType.swift — 1 commit
  • Sources/Tokenizer.swift — 1 commit
  • SwiftFormat.xcodeproj/project.pbxproj — 1 commit

Notable commits

  • fix: Fix --preserve-acronyms to work as substring match, not just exact identifier match (#2629)
  • fix: Fix preferLazyMap failing to terminate on an optional-chained receiver (#2666)
  • fix: Fix preferLazyMap rewrites that were not behavior-preserving (#2661)
  • fix: Fix redundantClosure false positive if statements with no else branch (#2659)
  • fix: Fix redundantSwiftUIGroup removing Group(subviews:) (#2624)
  • fix: Fix blank line before trailing infix operators (#2652)
  • fix: Fix building project with Xcode 27
  • fix: Fix environmentEntry edge cases (#2611)
  • fix: Fix genericExtensions rule leaving stray comma with additional where conditions (#2630)
  • fix: Fix indent dropping switch case body indentation inside #if with --ifdef no-indent (#2625)
  • fix: Fix indent of trailing closure in method chain member inside #if (#2604)
  • fix: Fix issue where swiftTestingTestCaseNames rule could accidentally not add backticks when required (#2637)
  • fix: Fix redundantInternal stripping required internal inside #if in non-internal extensions (#2607)
  • fix: Fix spaceAroundParens spurious violations for keyword identifiers after :: module selector (#2603)
  • fix: Fix spaces around module selectors in generics (#2660)
  • fix: fix: don't remove redundant returns from switch/if inside a flatMap closure (#2621)
  • change: Add Token.isLiteralIdentifier (#2662)
  • change: Add ifExpressions rule to convert ternaries to if expressions (#2634)
  • change: Add preferLazyMap rule (#2656)
  • change: Add redundantExtendedLifetime rule (#2671)
  • …and 26 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

nicklockwood/SwiftFormat was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 27 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 173d2cb252474cd8e8baeaf13636f5d565408ec9 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-d00c643c3f66.