Skip to content

Conversation

@leogdion
Copy link
Member

@leogdion leogdion commented Jul 17, 2025

Summary by CodeRabbit

  • New Features

    • Improved concurrency safety by updating several types and protocols to conform to the Sendable protocol.
    • Added a static method for creating ISO8601 date formatters, enhancing date parsing and formatting reliability.
  • Refactor

    • Replaced a shared ISO8601 date formatter instance with a factory method for better thread safety and maintainability.
    • Updated closure typealiases to explicitly mark them as @Sendable for safer concurrent use.
  • Chores

    • Expanded CI workflow triggers to run on pushes to all branches, increasing test coverage.

@coderabbitai
Copy link

coderabbitai bot commented Jul 17, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes update several types and closures to conform to the Sendable protocol for concurrency safety. The handling of ISO8601 date formatting is refactored to use a static factory method instead of a shared global instance. No core logic or control flow is altered, but concurrency annotations and date formatter instantiation are improved.

Changes

File(s) Change Summary
Sources/XMLCoder/Auxiliaries/Box/DateBox.swift DateBox now conforms to Sendable; uses ISO8601DateFormatter.xmlCoderFormatter() instead of a shared formatter.
Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift Replaces global _iso8601Formatter with static method xmlCoderFormatter() in an extension; removes availability checks.
Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift DynamicNodeEncoding protocol updated to conform to Sendable.
Sources/XMLCoder/Encoder/XMLEncoder.swift OutputFormatting and NodeEncoding updated to Sendable; closure typealiases now use @Sendable; closure handling updated for Swift 6.1+.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant DateBox
    participant ISO8601DateFormatter

    Caller->>DateBox: init?(iso8601: String)
    DateBox->>ISO8601DateFormatter: xmlCoderFormatter()
    ISO8601DateFormatter-->>DateBox: new formatter instance
    DateBox->>ISO8601DateFormatter: parse date string
    ISO8601DateFormatter-->>DateBox: Date?
    DateBox-->>Caller: DateBox?
Loading

Poem

In the warren, code now sends
Safely hopping through new threads—
Date strings parsed with care anew,
No global burrow to run into!
With Sendable, we leap and bound,
Concurrency safe, formatter sound.
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift (1)

17-17: Add trailing newline to fix SwiftLint warning.

 }
+
Sources/XMLCoder/Encoder/XMLEncoder.swift (1)

42-42: Fix colon spacing and approve Sendable conformance.

The NodeEncoding enum correctly conforms to Sendable as it's an enum that should be safe for concurrent access.

-    public enum NodeEncoding : Sendable {
+    public enum NodeEncoding: Sendable {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efda1cc and 5ec940f.

📒 Files selected for processing (4)
  • Sources/XMLCoder/Auxiliaries/Box/DateBox.swift (3 hunks)
  • Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift (1 hunks)
  • Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift (1 hunks)
  • Sources/XMLCoder/Encoder/XMLEncoder.swift (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Sources/XMLCoder/Auxiliaries/Box/DateBox.swift (1)
Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift (1)
  • xmlCoderFormatter (12-16)
🪛 SwiftLint (0.57.0)
Sources/XMLCoder/Encoder/XMLEncoder.swift

[Warning] 42-42: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals

(colon)

Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift

[Warning] 17-17: Files should have a single trailing newline

(trailing_newline)

🔇 Additional comments (8)
Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift (1)

11-17: LGTM! Good refactoring for concurrency safety.

The static factory method approach eliminates potential race conditions from shared global state and aligns well with Swift 6.2's concurrency requirements. Creating a new formatter instance on each call is the safer approach for concurrent usage.

Sources/XMLCoder/Auxiliaries/Box/DateBox.swift (3)

11-11: LGTM! Appropriate Sendable conformance.

The DateBox struct correctly conforms to Sendable as it's a value type with immutable properties, making it safe for concurrent access.


47-47: Good usage of the new factory method.

The replacement of the shared global formatter with ISO8601DateFormatter.xmlCoderFormatter() is consistent with the concurrency safety improvements.


73-73: Consistent usage of the factory method.

The formatter usage here is consistent with the other usage in the file and aligns with the concurrency safety refactoring.

Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift (1)

43-43: LGTM! Appropriate Sendable conformance for protocol.

The DynamicNodeEncoding protocol correctly conforms to Sendable as it only defines static methods and has no mutable state, making it safe for concurrent usage.

Sources/XMLCoder/Encoder/XMLEncoder.swift (3)

16-16: LGTM! Appropriate Sendable conformance.

The OutputFormatting struct correctly conforms to Sendable as it's an OptionSet with immutable properties, making it safe for concurrent access.


236-237: LGTM! Proper @sendable closure annotations.

The @Sendable annotations on the closure typealiases are essential for Swift 6.2 concurrency safety, ensuring these closures can be safely used across concurrency domains.


265-271: Excellent Swift version compatibility handling.

The conditional compilation approach elegantly handles the differences between Swift versions while maintaining concurrency safety. In Swift 6.1+, the method can be used directly, while earlier versions require the explicit @Sendable wrapper.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ec940f and 7ba3ef6.

📒 Files selected for processing (1)
  • .github/workflows/main.yml (1 hunks)

subrepo:
  subdir:   "Packages/XMLCoder"
  merged:   "2b2a748"
upstream:
  origin:   "git@github.com:brightdigit/XMLCoder.git"
  branch:   "syndikit-swift-6.2"
  commit:   "7ba3ef6"
git-subrepo:
  version:  "0.4.9"
  origin:   "https://github.com/Homebrew/brew"
  commit:   "23c491e5bc"
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Sources/XMLCoder/Encoder/XMLEncoder.swift (1)

42-42: Fix colon spacing and approve Sendable conformance.

The NodeEncoding enum correctly conforms to Sendable since it's a simple enum with associated values that are inherently sendable. However, there's a spacing issue with the colon.

Apply this diff to fix the colon spacing:

-    public enum NodeEncoding : Sendable {
+    public enum NodeEncoding: Sendable {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba3ef6 and 24bb33b.

📒 Files selected for processing (1)
  • Sources/XMLCoder/Encoder/XMLEncoder.swift (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Sources/XMLCoder/Encoder/XMLEncoder.swift (8)
Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift (2)
  • nodeEncoding (48-50)
  • nodeEncoding (54-56)
Tests/XMLCoderTests/NodeEncodingStrategyTests.swift (2)
  • nodeEncoding (46-48)
  • nodeEncoding (72-74)
Tests/XMLCoderTests/AdvancedFeatures/AttributedIntrinsicLegacyTest.swift (4)
  • nodeEncoding (89-96)
  • nodeEncoding (116-123)
  • nodeEncoding (135-142)
  • nodeEncoding (178-185)
Tests/XMLCoderTests/AdvancedFeatures/DynamicNodeDecodingLegacyTest.swift (2)
  • nodeEncoding (134-139)
  • nodeEncoding (151-158)
Tests/XMLCoderTests/AdvancedFeatures/AttributedIntrinsicTest.swift (1)
  • nodeEncoding (143-150)
Tests/XMLCoderTests/EscapedCharactersTest.swift (1)
  • nodeEncoding (60-62)
Tests/XMLCoderTests/AdvancedFeatures/DynamicNodeEncodingTest.swift (3)
  • nodeEncoding (124-129)
  • nodeEncoding (141-148)
  • nodeEncoding (289-296)
Tests/XMLCoderTests/RootLevetExtraAttributesTests.swift (1)
  • nodeEncoding (55-60)
🪛 SwiftLint (0.57.0)
Sources/XMLCoder/Encoder/XMLEncoder.swift

[Warning] 42-42: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals

(colon)

🔇 Additional comments (3)
Sources/XMLCoder/Encoder/XMLEncoder.swift (3)

16-16: Good addition of Sendable conformance for thread safety.

The OutputFormatting struct now conforms to Sendable, which is appropriate since it's an OptionSet with immutable properties that can be safely shared across concurrency boundaries.


236-237: Excellent use of @sendable for closure type safety.

The typealiases for XMLNodeEncoderClosure and XMLEncodingClosure are properly updated to use @Sendable, ensuring that closures of these types can be safely passed across concurrency boundaries. This is essential for Swift 6.2 strict concurrency checking.


265-271: Smart compiler version conditional for Sendable handling.

The implementation correctly handles the difference between Swift 6.1+ and earlier versions:

  • Swift 6.1+: Direct return of dynamicType.nodeEncoding(for:) method reference
  • Earlier versions: Explicit @Sendable closure wrapper

This approach maintains backward compatibility while leveraging improved method reference handling in newer Swift versions.

The logic is sound because:

  1. In Swift 6.1+, method references like dynamicType.nodeEncoding(for:) automatically inherit sendability from their context
  2. In earlier versions, the explicit @Sendable annotation ensures the closure meets the sendability requirements
  3. The relevant code snippets confirm that nodeEncoding(for:) implementations return XMLEncoder.NodeEncoding values, which are now Sendable

@leogdion leogdion changed the base branch from main to v1.0.0-alpha.1 July 17, 2025 19:12
@leogdion leogdion merged commit a3838b1 into v1.0.0-alpha.1 Jul 17, 2025
4 of 9 checks passed
@leogdion leogdion deleted the syndikit-swift-6.2 branch July 17, 2025 19:18
leogdion added a commit that referenced this pull request Jul 17, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jul 17, 2025
leogdion added a commit that referenced this pull request Dec 21, 2025
Adding Support for Swift 6 (#1)
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.

2 participants