Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECO-5027] Marked types with only readonly members as NS_SWIFT_SENDABLE #1988

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

maratal
Copy link
Collaborator

@maratal maratal commented Oct 8, 2024

Closes #1987

Summary by CodeRabbit

  • New Features

    • Introduced new enumerations for enhanced error handling: ARTDataQueryError, ARTRealtimeHistoryError, and ARTCustomRequestError.
    • Added new interfaces for channel metrics and statuses: ARTChannelMetrics, ARTChannelOccupancy, ARTChannelStatus, and ARTChannelDetails.
    • Expanded asynchronous handling capabilities with new callback typedefs: ARTChannelDetailsCallback and ARTStatusCallback.
  • Improvements

    • Updated existing interfaces to provide more detailed state change information.

@github-actions github-actions bot temporarily deployed to staging/pull/1988/features October 8, 2024 18:34 Inactive
@maratal maratal changed the title Marked types with only readonly members as NS_SWIFT_SENDABLE [ECO-5027] Marked types with only readonly members as NS_SWIFT_SENDABLE Oct 8, 2024
@github-actions github-actions bot temporarily deployed to staging/pull/1988/jazzydoc October 8, 2024 18:36 Inactive
@maratal maratal marked this pull request as ready for review October 8, 2024 19:01
Copy link

coderabbitai bot commented Oct 8, 2024

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Files that changed from the base of the PR and between 9125b11 and ed8f4ac.

📒 Files selected for processing (1)
  • Test/Tests/RealtimeClientChannelTests.swift (1 hunks)
____________________________________________
< Forcing bugs to surrender unconditionally. >
--------------------------------------------
 \
  \   \
       \ /\
       ( )
     .( o ).

Walkthrough

The changes in this pull request primarily involve the addition of new enumerations and interfaces in the ARTTypes.h file of the Ably library. New enumerations for various error types have been introduced, enhancing error handling. Additionally, existing interfaces for connection and channel state changes have been updated to include new parameters. New interfaces for channel metrics, occupancy, status, and details have been defined, along with new callback typedefs for improved asynchronous handling of channel and status information.

Changes

File Change Summary
Source/include/Ably/ARTTypes.h - Added enumerations: ARTDataQueryError, ARTRealtimeHistoryError, ARTCustomRequestError
- Updated ARTChannelStateChange and ARTConnectionStateChange initializers
- Added interfaces: ARTChannelMetrics, ARTChannelOccupancy, ARTChannelStatus, ARTChannelDetails
- Added typedefs: ARTChannelDetailsCallback, ARTStatusCallback

Assessment against linked issues

Objective Addressed Explanation
Address uses of @preconcurrency import Ably in ably-chat-swift#67 No changes related to @preconcurrency import.

Possibly related issues

  • Add Swift concurrency annotations #1962: The changes enhance error handling and channel management, which may relate to improving concurrency annotations.
  • ECO-4940: The addition of new types and interfaces could facilitate the implementation of Swift concurrency annotations in future updates.

🐇 In the meadow, I hop with glee,
New enums and types, oh what a spree!
With channels and states, we frolic and play,
Error handling's bright, come join the ballet!
Hopping high, our code takes flight,
In the world of Ably, everything feels right! 🌼

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting in your project's settings in CodeRabbit to automatically approve the review once all CodeRabbit's comments are resolved.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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

🧹 Outside diff range and nitpick comments (1)
Source/include/Ably/ARTTypes.h (1)

Mutable properties found in the following classes:

  • ARTConnectionStateChange
  • ARTChannelStateChange
🔗 Analysis chain

Line range hint 233-242: Verify that types marked as NS_SWIFT_SENDABLE comply with sendable requirements

The classes have been marked with NS_SWIFT_SENDABLE to indicate they are safe for concurrent use in Swift. To ensure correctness, we should verify that these types contain only immutable, readonly properties and do not have any mutable state.

Run the following script to check for any mutable properties in these classes:

This script searches for any @property declarations within the specified classes that are not marked as (readonly). The absence of mutable properties confirms that the classes are appropriate for the NS_SWIFT_SENDABLE attribute.

Also applies to: 277-292, 323-345, 369-377, 385-395, 406-414

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that classes marked as NS_SWIFT_SENDABLE contain only readonly properties.

# Classes to check
classes=(
  "ARTConnectionStateChange"
  "ARTChannelStateChange"
  "ARTChannelMetrics"
  "ARTChannelOccupancy"
  "ARTChannelStatus"
  "ARTChannelDetails"
)

# Use ast-grep to find mutable properties in each class
for class in "${classes[@]}"; do
  echo "Checking class $class..."
  ast-grep --lang objective-c --pattern $'@interface '$class' : $_ {
    $$$
  }
  %{
    @property ($$$) $__ __$__;
  }' | grep -v '(readonly)' | grep '@property' && echo "Mutable property found in $class" || echo "No mutable properties in $class"
done

Length of output: 3203


Script:

#!/bin/bash
# Description: Verify that classes marked as NS_SWIFT_SENDABLE contain only readonly properties using ast-grep with corrected language.

# Classes to check
classes=(
  "ARTConnectionStateChange"
  "ARTChannelStateChange"
  "ARTChannelMetrics"
  "ARTChannelOccupancy"
  "ARTChannelStatus"
  "ARTChannelDetails"
)

# Use ast-grep to find mutable properties in each class with corrected language identifier
for class in "${classes[@]}"; do
  echo "Checking class $class..."
  ast-grep --lang objc --pattern $'@interface '$class' : $_ {
    $$$
  }
  %{
    @property ($$$) $__ __$__;
  }' | grep -v '(readonly)' | grep '@property' && echo "Mutable property found in $class" || echo "No mutable properties in $class"
done

Length of output: 3077


Script:

#!/bin/bash
# Description: Verify that classes marked as NS_SWIFT_SENDABLE contain only readonly properties using ripgrep.

# Classes to check
classes=(
  "ARTConnectionStateChange"
  "ARTChannelStateChange"
  "ARTChannelMetrics"
  "ARTChannelOccupancy"
  "ARTChannelStatus"
  "ARTChannelDetails"
)

# Use ripgrep to find mutable properties in each class
for class in "${classes[@]}"; do
  echo "Checking class $class..."
  # Extract the @interface block for the class and search for @property without (readonly)
  rg -A 50 "@interface $class" | rg "@property" | grep -v "readonly" && echo "Mutable property found in $class" || echo "No mutable properties in $class"
done

Length of output: 2102

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ccca241 and 9125b11.

📒 Files selected for processing (1)
  • Source/include/Ably/ARTTypes.h (6 hunks)
🧰 Additional context used
🔇 Additional comments (7)
Source/include/Ably/ARTTypes.h (7)

Line range hint 233-242: Addition of retryIn parameter enhances reconnection control in ARTConnectionStateChange

The introduction of the retryIn parameter and property allows clients to specify the retry interval after a connection state change, providing finer control over reconnection behavior.


Line range hint 277-292: Inclusion of resumed parameter in ARTChannelStateChange improves continuity handling

By adding the resumed parameter and property, the ARTChannelStateChange class now indicates whether message continuity on a channel is preserved, which is essential for client applications to handle reconnections and data consistency.


Line range hint 323-345: New ARTChannelMetrics class accurately defines channel metrics properties

The ARTChannelMetrics interface introduces properties that provide comprehensive metrics about the channel, such as the number of connections, publishers, and subscribers. This enhancement facilitates better monitoring and analytics of channel usage.


Line range hint 369-377: ARTChannelOccupancy class encapsulates channel occupancy metrics effectively

The ARTChannelOccupancy class, containing the ARTChannelMetrics object, provides a clear structure for accessing occupancy information of a channel, aiding in resource management and optimization.


Line range hint 385-395: ARTChannelStatus class accurately represents channel active state and occupancy

Introducing the ARTChannelStatus class with active and occupancy properties allows clients to determine the current status of a channel easily, improving the ability to make informed decisions based on channel state.


Line range hint 406-414: ARTChannelDetails class provides comprehensive channel information

The ARTChannelDetails class encapsulates both the channel identifier and its status, offering a detailed view of the channel's state and metrics, which is beneficial for management and debugging purposes.


Line range hint 432-433: Addition of callback typedefs enhances code readability and maintainability

The new typedefs ARTChannelDetailsCallback and ARTStatusCallback improve the clarity of asynchronous code by providing descriptive names for callback blocks, making the codebase more understandable and easier to maintain.

@github-actions github-actions bot temporarily deployed to staging/pull/1988/features October 8, 2024 21:31 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1988/jazzydoc October 8, 2024 21:35 Inactive
@maratal maratal merged commit 39bcedf into main Oct 9, 2024
12 of 15 checks passed
@maratal maratal deleted the fix/1987-avoiding-preconcurrency branch October 9, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Address uses of @preconcurrency import Ably in ably-chat-swift#67
2 participants