Skip to content

Latest commit

 

History

History
87 lines (62 loc) · 3.27 KB

File metadata and controls

87 lines (62 loc) · 3.27 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Commands

Building and Testing

# Build the package
swift build

# Run tests
swift test

# Run specific test
swift test --filter TestName

Code Quality

# Format code
swiftformat . --config shared-swiftformat.yml

# Lint code
swiftlint lint --config shared-swiftlint.yml

# Test custom SwiftLint rules (regex-based)
cd swiftlint-tests && ./test-swiftlint-rules.sh

# Test SwiftSyntax-based rules (more accurate, better performance)
cd swiftlint-swiftsyntax-integration && ./scripts/check-file.sh path/to/file.swift
cd swiftlint-swiftsyntax-integration && ./scripts/check-project.sh path/to/project

Architecture

Package Structure

SynodicTools is a zero-dependency Swift utility library providing extensions and data structures for iOS 15+ and macOS 12+ development. The architecture is extension-based with strong emphasis on code quality through comprehensive tooling.

Core Components

Mathematical Utilities:

  • Fraction.swift: Complete fraction implementation with mixed number support
  • BinaryFloatingPoint+Extensions.swift: Inverse linear interpolation functionality
  • Percent.swift: Property wrapper for percentage handling with type conversions

Collection Extensions:

  • Array+Extensions.swift: Statistical functions and interspacing utilities
  • Collection+Extensions.swift: Safe indexing with subscript(safeIndex:)
  • RangeReplaceableCollection+Extensions.swift: Safe appending to optional collections

Foundation & SwiftUI Extensions:

  • Calendar+Extensions.swift: Date utilities (start of week/month/year)
  • View+ModifierGroup.swift: View modifier grouping functionality

Code Quality System

The codebase uses an extensive quality assurance system:

  1. SwiftFormat Configuration (shared-swiftformat.yml): 100+ formatting rules targeting Swift 6.0

  2. SwiftLint Configuration (shared-swiftlint.yml): Custom rules including:

    • Skimmable SwiftUI body (10 lines max)
    • SwiftUI View structure enforcement (property ordering)
    • Spacer vs. frame alignment patterns
    • Performance optimizations
  3. Custom Rule Testing (swiftlint-tests/): Comprehensive test suite validating all custom SwiftLint rules

  4. SwiftSyntax Integration (swiftlint-swiftsyntax-integration/): Advanced SwiftSyntax-based rules for accurate AST analysis

Development Patterns

  • Extension-Based Design: All functionality provided through Swift extensions
  • Protocol-Oriented Programming: Generic implementations using Swift protocols
  • Type Safety: Strong typing with property wrappers and custom types
  • Public API Design: Clear naming conventions and inline documentation

Testing Strategy

Focus testing on complex functionality and edge cases. The swiftlint-tests/ directory contains validation tests for all custom linting rules.

Key Considerations

  • Zero Dependencies: Keep the package self-contained
  • Platform Support: iOS 15+ and macOS 12+ minimum
  • Swift Version: Targeting Swift 6.0 for future-proofing
  • Code Quality: All changes must pass both SwiftFormat and SwiftLint validation
  • Testing: Use Swift Testing framework for new tests, migrate existing XCTest code when possible