Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
29fc0f8
Reinstate SwiftLint complexity thresholds
SoundBlaster Nov 19, 2025
30bf3e0
Refactored the JSON exporter so it now passes the type_body_length gate
SoundBlaster Nov 25, 2025
b6f12b2
bug
SoundBlaster Nov 25, 2025
54b684b
Fixed the strict-concurrency Sendable regression and got the smoke tests
SoundBlaster Nov 25, 2025
3a68f10
Prefix method calls with self in DocumentSessionController.swift
SoundBlaster Nov 25, 2025
6d7ad78
• Fix Applied
SoundBlaster Nov 25, 2025
bd338ec
- Removed the stray identifier_name config block from .swiftlint.yml so
SoundBlaster Nov 25, 2025
66b7088
- Adjusted CI lint step in .github/workflows/ci.yml so the strict
SoundBlaster Nov 25, 2025
00da7bb
Try to fix SwiftLint on pre commit/push
SoundBlaster Nov 27, 2025
615b414
Add SwiftLint baseline support and refactor JSONParseTreeExporter
SoundBlaster Nov 27, 2025
3f7a69f
Task A7: Complete large file refactoring - BoxValidator & DocumentSes…
claude Nov 28, 2025
e2cef4b
Add CI failure analysis document for Task A7 refactoring
claude Nov 28, 2025
f3ff4da
Fix duplicate extension declarations in VersionFlagsRule.swift
claude Nov 28, 2025
0aee83b
Update CI failure analysis - build error fixed
claude Nov 28, 2025
34020aa
Fix MappedValue initialization errors in JSONParseTreeExporter
claude Nov 28, 2025
abcaf9c
Update CI failure analysis - all build errors fixed
claude Nov 28, 2025
f86d767
Fix string interpolation syntax errors in Services
claude Nov 28, 2025
46f4dfa
Update CI_FAILURE_ANALYSIS.md with string interpolation fix
claude Nov 28, 2025
8aefc71
Update SwiftLint Docker image to 0.57.0 for baseline support
claude Nov 28, 2025
b5e118f
Document SwiftLint version fix in CI_FAILURE_ANALYSIS.md
claude Nov 28, 2025
76165f9
Fix compilation errors from service extraction
claude Nov 29, 2025
ea6512e
Document compilation errors and remaining SwiftLint violations
claude Nov 29, 2025
9278aa6
Disable vertical_whitespace rule and update swiftlint-format.sh
claude Nov 29, 2025
4cec58d
Document vertical whitespace autocorrect fix
claude Nov 29, 2025
9c7679d
Add SwiftLint suppressions to ValidationRules
claude Nov 29, 2025
32b3ef0
Document SwiftLint ValidationRules suppressions
claude Nov 29, 2025
08b539d
Add SwiftLint suppressions to remaining Services files
claude Nov 29, 2025
58e20a5
Document Services type_body_length suppressions
claude Nov 29, 2025
0a6d540
Fix CI build failure after DocumentSessionController refactoring
SoundBlaster Nov 29, 2025
5837686
Fix rational SwiftLint violations (28 → 10)
SoundBlaster Nov 29, 2025
f335ea7
Fix SwiftLint issues
SoundBlaster Nov 29, 2025
9ac2e86
Fix macOS build
SoundBlaster Nov 29, 2025
f389438
Reformat
SoundBlaster Nov 29, 2025
2117d77
Reorder content
SoundBlaster Nov 29, 2025
a68f9e8
Linting
SoundBlaster Nov 29, 2025
9834a2b
Decrease cyclomatic complexity in the ParseTreeStore
SoundBlaster Nov 29, 2025
4c07340
Simplify ParseEventCapturePayload
SoundBlaster Nov 29, 2025
bd24bd2
Simplify `synthesizePlaceholdersIfNeeded` of ParseTreeBuilder
SoundBlaster Nov 29, 2025
9f16e54
Simplify ParseTreeBuilder `consume` function
SoundBlaster Nov 29, 2025
7cc1995
Simplify ParseTreeBuilder
SoundBlaster Nov 29, 2025
fac277f
Simplify ParseTreeOutlineViewModel
SoundBlaster Nov 29, 2025
c8ec1a5
Simplify CoreDataAnnotationBookmarkStore
SoundBlaster Nov 29, 2025
ed5892e
Simplify big structs and classes
SoundBlaster Nov 29, 2025
86afad7
Disable type_body_length for Tests
SoundBlaster Nov 29, 2025
a45f437
Simplify ParsePipeline
SoundBlaster Nov 29, 2025
aa369dc
Simplify ParseTreeOutlineView.swift
SoundBlaster Nov 29, 2025
b843acc
Fix SwiftLint rules
SoundBlaster Nov 29, 2025
f58f3b2
Simplify ParseTreeDetailViewModel
SoundBlaster Nov 29, 2025
1d4ebaf
Simplify EncryptionSummary
SoundBlaster Nov 29, 2025
d4ac8f3
Next steps of simplifications
SoundBlaster Nov 29, 2025
ba56938
Fix SwiftLint issues
SoundBlaster Nov 29, 2025
59059ec
Fix SwiftLint issues
SoundBlaster Dec 2, 2025
8ec867e
Disable linter rule vertical_parameter_alignment
SoundBlaster Dec 2, 2025
15cb38e
Add todos in the code
SoundBlaster Dec 2, 2025
2d9f163
Disable function_body_length
SoundBlaster Dec 2, 2025
2372437
Disable cyclomatic_complexity
SoundBlaster Dec 2, 2025
a2f5255
Fix SwiftLint (again)
SoundBlaster Dec 3, 2025
6f55faf
Fix formatting and accessibility improvements in UI modifiers
SoundBlaster Dec 3, 2025
0a6a6c6
Replace deprecated content closure with detail closure in Sidebar
SoundBlaster Dec 5, 2025
2bf68a6
Change isAccessibilityCategory to fileprivate for broader scope within
SoundBlaster Dec 5, 2025
9e817c3
Make conditional view modifier method fileprivate and reformat
SoundBlaster Dec 5, 2025
049d8cc
Fix compilation issues
SoundBlaster Dec 5, 2025
b438b74
Fix macOS window style and toolbar style placement
SoundBlaster Dec 5, 2025
55dd9bb
Refactor InteractiveStyle to use let bindings in body
SoundBlaster Dec 5, 2025
174c31b
Change isAccessibilityCategory from fileprivate to private
SoundBlaster Dec 5, 2025
bc601ad
Make View extension helper private and simplify formatting
SoundBlaster Dec 5, 2025
bc6da9d
Expose isAccessibilityCategory property in DynamicTypeSize extension
SoundBlaster Dec 5, 2025
2c166db
Refactor range calculation for clarity in test case
SoundBlaster Dec 5, 2025
0a63bfd
SwiftLint fix
SoundBlaster Dec 5, 2025
20347ff
Remove detailed comments from ISOInspectorDemoScreen.swift header
SoundBlaster Dec 5, 2025
70cf60e
Disable type_body_length
SoundBlaster Dec 5, 2025
0a4d778
Disable SwiftFormat `multiElementCollectionTrailingCommas`
SoundBlaster Dec 5, 2025
9bfa56a
swiftformat
SoundBlaster Dec 5, 2025
cace19b
disable swiftformat
SoundBlaster Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
95 changes: 72 additions & 23 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,91 @@ run_swiftlint() {
-u "$(id -u):$(id -g)" \
-v "$REPO_ROOT:/work" \
-w "/work/$target_dir" \
ghcr.io/realm/swiftlint:0.53.0 \
ghcr.io/realm/swiftlint:0.57.0 \
swiftlint "$@"
else
return 1
fi
}

# Check for SwiftLint violations
lint_staged_files() {
local label="$1"
local target_dir="$2"
local config_path="$3"
local baseline_path="$4"
shift 4
local files=("$@")

if [ ${#files[@]} -eq 0 ]; then
return 0
fi

local config_args=()
if [ -n "$config_path" ]; then
config_args=(--config "$config_path")
fi

local baseline_args=()
if [ -n "$baseline_path" ] && [ -f "$target_dir/$baseline_path" ]; then
baseline_args=(--baseline "$baseline_path")
fi

echo " • $label: ${#files[@]} staged file(s)"

local lint_failed=0
for file in "${files[@]}"; do
if ! run_swiftlint "$target_dir" lint --strict --quiet "${config_args[@]}" "${baseline_args[@]}" --path "$file"; then
echo " ↳ ❌ $file"
lint_failed=1
fi
done

if [ $lint_failed -eq 0 ]; then
echo " ↳ ✅ Passed"
return 0
fi

return 1
}

# Check for SwiftLint violations on staged files
if [ "$SWIFTLINT_MODE" != "none" ]; then
echo "1️⃣ Checking code style with SwiftLint (${SWIFTLINT_MODE})..."

STAGED_SWIFT_FILES=$(git diff --cached --name-only --diff-filter=ACM 2>/dev/null | grep '\.swift$' || true)

if [ -n "$STAGED_SWIFT_FILES" ]; then
# Check FoundationUI files
FOUNDATIONUI_FILES=$(echo "$STAGED_SWIFT_FILES" | grep '^FoundationUI/' || true)
if [ -n "$FOUNDATIONUI_FILES" ]; then
if run_swiftlint "FoundationUI" --config .swiftlint.yml --quiet; then
echo "✅ FoundationUI: Code style check passed"
else
echo "❌ FoundationUI: SwiftLint violations found"
echo " Run: cd FoundationUI && swiftlint --config .swiftlint.yml --fix"
FAILED=$((FAILED + 1))
fi
fi
readarray -t STAGED_SWIFT_FILES_ARRAY <<< "$STAGED_SWIFT_FILES"

MAIN_FILES=()
FOUNDATIONUI_FILES=()
COMPONENT_FILES=()

for file in "${STAGED_SWIFT_FILES_ARRAY[@]}"; do
case "$file" in
FoundationUI/*)
FOUNDATIONUI_FILES+=("${file#FoundationUI/}")
;;
Examples/ComponentTestApp/*)
COMPONENT_FILES+=("${file#Examples/ComponentTestApp/}")
;;
*)
MAIN_FILES+=("$file")
;;
esac
done

GROUP_FAILED=0
lint_staged_files "Main project" "." "" ".swiftlint.baseline.json" "${MAIN_FILES[@]}" || GROUP_FAILED=1
lint_staged_files "FoundationUI" "FoundationUI" ".swiftlint.yml" "" "${FOUNDATIONUI_FILES[@]}" || GROUP_FAILED=1
lint_staged_files "ComponentTestApp" "Examples/ComponentTestApp" "" ".swiftlint-baseline.json" "${COMPONENT_FILES[@]}" || GROUP_FAILED=1

# Check ComponentTestApp files
COMPONENTTESTAPP_FILES=$(echo "$STAGED_SWIFT_FILES" | grep '^Examples/ComponentTestApp/' || true)
if [ -n "$COMPONENTTESTAPP_FILES" ]; then
if run_swiftlint "Examples/ComponentTestApp" --quiet; then
echo "✅ ComponentTestApp: Code style check passed"
else
echo "❌ ComponentTestApp: SwiftLint violations found"
echo " Run: cd Examples/ComponentTestApp && swiftlint --fix"
FAILED=$((FAILED + 1))
fi
if [ $GROUP_FAILED -ne 0 ]; then
echo "❌ SwiftLint violations detected in staged files"
echo " Run 'swiftlint lint --strict' (or cd into the scoped directory) to view details."
FAILED=$((FAILED + 1))
else
echo "✅ All staged Swift files pass SwiftLint"
fi
else
echo "⚠️ No Swift files staged"
Expand Down
4 changes: 2 additions & 2 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ echo ""
# 1. Check for SwiftLint violations (if installed)
echo "1️⃣ Checking code quality with SwiftLint (strict mode)..."
if command -v swiftlint &> /dev/null; then
if swiftlint lint --strict --quiet; then
if swiftlint lint --strict --quiet --baseline .swiftlint.baseline.json; then
echo -e "${GREEN}✅ SwiftLint check passed${NC}"
else
echo -e "${RED}❌ SwiftLint violations found${NC}"
echo " Run: swiftlint lint"
echo " Run: swiftlint lint --strict --baseline .swiftlint.baseline.json"
echo " Fix auto-fixable issues: swiftlint --fix"
FAILED=$((FAILED + 1))
fi
Expand Down
29 changes: 3 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,6 @@ jobs:
- name: Validate JSON formatting
run: ./scripts/validate_json.py

swift-format-check:
name: Swift Format Check
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Swift
uses: SwiftyLab/setup-swift@v1
with:
swift-version: '6.0'

- name: Check Swift formatting (lint mode)
run: |
echo "Checking Swift code formatting..."
swift format lint --recursive Sources Tests
if [ $? -ne 0 ]; then
echo "::error::Swift code is not formatted correctly. Run locally:"
echo " swift format --in-place --recursive Sources Tests"
exit 1
fi
echo "All Swift files are correctly formatted."

swiftlint-complexity:
name: SwiftLint Complexity Check
runs-on: macos-latest
Expand All @@ -109,12 +86,12 @@ jobs:
run: brew install swiftlint

- name: Run SwiftLint (strict mode)
continue-on-error: true
run: |
swiftlint lint --strict --reporter sarif > swiftlint-report.sarif || true
swiftlint lint --strict
swiftlint lint --strict --config .swiftlint.yml --baseline .swiftlint.baseline.json --reporter sarif > swiftlint-report.sarif || true

- name: Upload SwiftLint SARIF report
if: failure()
if: always()
uses: actions/upload-artifact@v4
with:
name: swiftlint-report
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/swift-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
- name: SwiftLint autocorrect check
run: |
set -euo pipefail
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/work" -w /work ghcr.io/realm/swiftlint:0.53.0 \
/bin/sh -lc 'rm -f .swiftlint.cache; swiftlint --fix --no-cache --config .swiftlint.yml'
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/work" -w /work ghcr.io/realm/swiftlint:0.57.0 \
/bin/sh -lc 'rm -f .swiftlint.cache; swiftlint --fix --no-cache --config .swiftlint.yml --baseline .swiftlint.baseline.json'
if ! git diff --quiet; then
echo "::error::SwiftLint --fix produced changes. Run scripts/swiftlint-format.sh locally and commit."
git --no-pager diff --name-only
Expand All @@ -56,8 +56,8 @@ jobs:

- name: SwiftLint (verify)
run: |
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/work" -w /work ghcr.io/realm/swiftlint:0.53.0 \
swiftlint lint --strict --no-cache --config .swiftlint.yml
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/work" -w /work ghcr.io/realm/swiftlint:0.57.0 \
swiftlint lint --strict --no-cache --config .swiftlint.yml --baseline .swiftlint.baseline.json

- name: Cache SwiftPM build artifacts
uses: actions/cache@v4
Expand Down
71 changes: 25 additions & 46 deletions .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,14 @@ jobs:
# Verify installation
swiftlint --version

# @todo #A7 Switch to strict mode after refactoring large files
# Currently running in informational mode (no --strict flag) because 3 files
# exceed type_body_length threshold. After refactoring JSONParseTreeExporter.swift,
# BoxValidator.swift, and DocumentSessionController.swift to <1500 lines each,
# change this to: swiftlint lint --strict --config .swiftlint.yml
# and remove the continue-on-error or make it fail on ERRORS > 0.
- name: Run SwiftLint on Main Project (Sources & Tests)
id: swiftlint-main
continue-on-error: true
run: |
set -eo pipefail

echo "🔍 Running SwiftLint on main project (Sources/, Tests/)..."
echo "⚠️ NOTE: Running in INFORMATIONAL mode while existing violations are being addressed"
swiftlint lint --config .swiftlint.yml --reporter json > /tmp/swiftlint-main.json || true
swiftlint lint --strict --baseline .swiftlint.baseline.json --reporter json | tee /tmp/swiftlint-main.json

# Parse and display results
if command -v jq &> /dev/null; then
Expand All @@ -93,12 +86,8 @@ jobs:
echo " Warnings: $WARNINGS"

if [ "$ERRORS" -gt 0 ]; then
echo "⚠️ SwiftLint errors found in main project (informational only)"
echo ""
echo "Top violations:"
swiftlint lint --config .swiftlint.yml --reporter xcode | head -50
echo ""
echo "💡 These are being tracked for future cleanup - not blocking merge"
echo "❌ SwiftLint errors found in main project"
swiftlint lint --strict --baseline .swiftlint.baseline.json --reporter xcode | head -50
fi
fi

Expand All @@ -118,7 +107,7 @@ jobs:
cd FoundationUI

echo "🔍 Running SwiftLint on FoundationUI..."
swiftlint --config .swiftlint.yml --reporter json > /tmp/swiftlint-foundationui.json || true
swiftlint lint --strict --reporter json | tee /tmp/swiftlint-foundationui.json

# Parse and display results
if command -v jq &> /dev/null; then
Expand All @@ -136,7 +125,7 @@ jobs:

if [ "$ERRORS" -gt 0 ]; then
echo "❌ SwiftLint errors found!"
swiftlint --config .swiftlint.yml --reporter xcode
swiftlint lint --strict --reporter xcode
exit 1
fi
fi
Expand All @@ -157,7 +146,7 @@ jobs:
cd Examples/ComponentTestApp

echo "🔍 Running SwiftLint on ComponentTestApp..."
swiftlint --reporter json > /tmp/swiftlint-componenttestapp.json || true
swiftlint lint --strict --baseline .swiftlint-baseline.json --reporter json | tee /tmp/swiftlint-componenttestapp.json

# Parse and display results
if command -v jq &> /dev/null; then
Expand All @@ -175,7 +164,7 @@ jobs:

if [ "$ERRORS" -gt 0 ]; then
echo "❌ SwiftLint errors found!"
swiftlint --reporter xcode
swiftlint lint --strict --baseline .swiftlint-baseline.json --reporter xcode
exit 1
fi
fi
Expand Down Expand Up @@ -236,10 +225,12 @@ jobs:
comment += "### 🔧 How to Fix\n\n";
comment += "Run locally:\n";
comment += "```bash\n";
comment += "# Check violations\n";
comment += "swiftlint lint --strict --config .swiftlint.yml\n\n";
comment += "# Auto-fix when possible\n";
comment += "swiftlint --fix --config .swiftlint.yml\n";
comment += "# Check violations (main project baseline)\n";
comment += "swiftlint lint --strict --config .swiftlint.yml --baseline .swiftlint.baseline.json\n\n";
comment += "# ComponentTestApp baseline\n";
comment += "cd Examples/ComponentTestApp && swiftlint lint --strict --baseline .swiftlint-baseline.json\n\n";
comment += "# Auto-fix when possible (respects baselines)\n";
comment += "swiftlint --fix --config .swiftlint.yml --baseline .swiftlint.baseline.json\n";
comment += "```\n";
}

Expand All @@ -258,38 +249,26 @@ jobs:
COMPONENTTESTAPP_RESULT="${{ steps.swiftlint-componenttestapp.outcome }}"

echo "📊 SwiftLint Quality Gate Results:"
echo " Main Project: $MAIN_RESULT (informational only - not blocking)"
echo " Main Project: $MAIN_RESULT"
echo " FoundationUI: $FOUNDATIONUI_RESULT"
echo " ComponentTestApp: $COMPONENTTESTAPP_RESULT"
echo ""

# Only block on FoundationUI and ComponentTestApp failures
# Main project violations are tracked but not blocking while cleanup is in progress
if [ "$FOUNDATIONUI_RESULT" = "failure" ] || [ "$COMPONENTTESTAPP_RESULT" = "failure" ]; then
if [ "$MAIN_RESULT" = "failure" ] || [ "$FOUNDATIONUI_RESULT" = "failure" ] || [ "$COMPONENTTESTAPP_RESULT" = "failure" ]; then
echo "❌ SwiftLint quality gate failed!"
echo ""
echo "Next steps:"
echo "1. Review violations reported above"
echo "2. Fix code style and complexity issues:"
echo " - FoundationUI: cd FoundationUI && swiftlint --config .swiftlint.yml --fix"
echo " - ComponentTestApp: cd Examples/ComponentTestApp && swiftlint --fix"
echo "3. Commit fixed code"
echo "4. Push changes"
echo ""
echo "Next steps:"
echo "1. Review violations reported above"
echo "2. Fix code style and complexity issues:"
echo " - Main Project: swiftlint lint --strict --config .swiftlint.yml --baseline .swiftlint.baseline.json"
echo " - FoundationUI: cd FoundationUI && swiftlint --config .swiftlint.yml --fix"
echo " - ComponentTestApp: cd Examples/ComponentTestApp && swiftlint lint --strict --baseline .swiftlint-baseline.json"
echo "3. Commit fixed code"
echo "4. Push changes"
echo ""
echo "💡 Tip: Download the SwiftLint report artifacts for detailed analysis"
exit 1
else
echo "✅ SwiftLint quality gate passed!"
echo ""
if [ "$MAIN_RESULT" = "failure" ]; then
echo "⚠️ NOTE: Main project has violations (see artifacts) but these are"
echo " being tracked for future cleanup and are not blocking merges yet."
echo ""
echo "📋 Known large files requiring refactoring:"
echo " - JSONParseTreeExporter.swift (2127 lines)"
echo " - BoxValidator.swift (1738 lines)"
echo " - DocumentSessionController.swift (1634 lines)"
else
echo "All enforced code meets complexity and style requirements."
fi
echo "All enforced code meets complexity and style requirements."
fi
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ repos:
# Swift linting with SwiftLint
- repo: local
hooks:
- id: swiftlint-autocorrect-multiple-closures
name: SwiftLint Autocorrect (Multiple Closures)
entry: scripts/swiftlint_autocorrect_multiple_closures.sh
language: system
pass_filenames: false
types: [swift]
stages: [pre-commit]
description: Auto-fix multi-closure trailing closure violations before linting

- id: swiftlint-foundationui
name: SwiftLint (FoundationUI)
entry: sh -c 'cd FoundationUI && swiftlint --config .swiftlint.yml --strict'
Expand Down
2 changes: 1 addition & 1 deletion .swift-format.json → .swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lineBreakBetweenDeclarationAttributes" : false,
"lineLength" : 100,
"maximumBlankLines" : 1,
"multiElementCollectionTrailingCommas" : true,
"multiElementCollectionTrailingCommas" : false,
"noAssignmentInExpressions" : {
"allowedFunctions" : [
"XCTAssertNoThrow"
Expand Down
1 change: 1 addition & 0 deletions .swiftlint.baseline.json

Large diffs are not rendered by default.

Loading