Skip to content

Consistent formatting: 4 spaces, swift-format, and self only where needed - #226

Merged
swhitty merged 4 commits into
mainfrom
claude/indent-4-spaces
Nov 17, 2026
Merged

swhitty merged 4 commits into
mainfrom
claude/indent-4-spaces

Conversation

@swhitty

@swhitty swhitty commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

A single formatting PR. Please merge with a merge commit, not a squash, so the SHAs listed in .git-blame-ignore-revs stay valid.

Commits

  1. Indent with 4 spaces throughout (f048571). 37 files used 2-space indentation in whole or part, and Package.swift had two tab-indented lines. Only leading whitespace changes. Multi-line string literals move as a whole, so their content is unchanged.

  2. Use self only where Swift needs it, and always in init (37f125a). A one-off pass with SwiftFormat's redundantSelf rule (--self init-only), across 27 files and 84 lines:

    • 36 redundant self. removed;
    • 46 added inside initialisers.

    Every changed line is identical apart from self.. Where Swift requires self (shadowed names, escaping closures in classes), it stays.

  3. Format with swift-format (d19fc38). Adds .swift-format and formats every Swift file, including Tools/. The settings:

    • 4-space indentation and 120-character lines;
    • one argument per line with the closing bracket on its own line (lineBreakBeforeEachArgument), and the return type kept with the );
    • #if blocks not indented.

    Every rewriting rule is off, so only layout changes: whitespace, line breaks, and trailing commas in multi-line collection literals. Three end-of-line comments that ran past the limit move onto their own lines.

  4. Ignore the formatting commits in blame, and document the style (8768bdf). .git-blame-ignore-revs lists commits 1 and 3. The self commit isn't listed, since it changes code. AGENTS.md describes the layout, how to run swift format, and the self convention, which swift-format doesn't check. .editorconfig (from commit 1) makes editors default to 4 spaces.

swift format ships with Swift, so anyone can run it:

swift format format --in-place --recursive .

There's no CI check yet. swift format lint --strict --recursive . is clean on this branch, and a second format run changes nothing.

Checks

  • swift build --build-tests, and swift test on macOS: 309 XCTest tests plus 785 + 442 Swift Testing tests. That includes the code-generation tests, which compare exact output.
  • ./container-run-tests.sh on Swift 6.4, and SWIFT_VERSION=6.2 (1,029 tests): all pass.
  • Tools/swiftdraw-diff and Tools/webkit-render tests pass.
  • swiftdraw-diff compare --base main --resvg Samples.bundle: all 181 samples unchanged, no regressions.

🤖 Generated with Claude Code

37 files still used 2-space indentation, in whole or in part, and
Package.swift had two tab-indented lines. Their 2-space indentation steps
become 4 spaces; nothing else changes.

- Only leading whitespace changes: every line is identical once its
  indentation is removed.
- Continuation lines aligned under an opening parenthesis stay aligned.
- Multi-line string literals (generated Swift, SVG test input) move as a
  whole with their closing delimiter, so their content is unchanged.

Adds .editorconfig (4 spaces; YAML 2) and a Formatting note in AGENTS.md.
A one-off pass with SwiftFormat's redundantSelf rule (--self init-only):
explicit self is removed where it is redundant, and added inside
initialisers for their own properties and methods. Only `self.` changes;
every changed line is otherwise identical.
Adds .swift-format: 4-space indentation, 120-character lines, and once a
call, signature or collection wraps, one argument per line with the
closing bracket on its own line. Every rewriting rule is off, so this
commit only changes layout: whitespace, line breaks, and trailing commas
in multi-line collection literals.

Three end-of-line comments that pushed their lines past the limit move
onto their own lines. `swift format lint --strict --recursive .` is clean,
and formatting again changes nothing.
.git-blame-ignore-revs lists the indentation and swift-format commits so
git blame and GitHub skip them. AGENTS.md describes the layout, how to run
swift format, and the self convention swift-format doesn't check.
@swhitty swhitty changed the title Indent with 4 spaces throughout Consistent formatting: 4 spaces, swift-format, and self only where needed Nov 17, 2026
@swhitty
swhitty merged commit 746e237 into main Nov 17, 2026
18 checks passed
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.31123% with 343 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.48%. Comparing base (5efe2b7) to head (8768bdf).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
SwiftDraw/Sources/Renderer/Renderer.CGText.swift 86.75% 69 Missing ⚠️
SwiftDraw/Sources/SVGView.swift 0.00% 51 Missing ⚠️
...ftDraw/Sources/Renderer/Renderer.CGText+Path.swift 70.00% 33 Missing ⚠️
SwiftDraw/Sources/Utilities/CGImage+Mask.swift 51.92% 25 Missing ⚠️
...tDraw/Sources/Renderer/Renderer.CoreGraphics.swift 93.79% 19 Missing ⚠️
...Sources/LayerTree/LayerTree.CommandGenerator.swift 94.64% 18 Missing ⚠️
...Draw/Sources/CommandLine/CommandLine+Process.swift 5.55% 17 Missing ⚠️
SwiftDraw/Sources/Utilities/FilterBitmap.swift 87.96% 16 Missing ⚠️
DOM/Sources/Parser.XML.Color.swift 94.53% 10 Missing ⚠️
...iftDraw/Sources/Renderer/CGTextRenderer+Code.swift 71.42% 10 Missing ⚠️
... and 26 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
+ Coverage   95.23%   95.48%   +0.24%     
==========================================
  Files         296      296              
  Lines       31260    35029    +3769     
==========================================
+ Hits        29772    33449    +3677     
- Misses       1488     1580      +92     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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