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-4968] Added missed NS_SWIFT_SENDABLE #3

Conversation

ruancomelli
Copy link
Collaborator

By analogy with ARTRealtimePresenceQuery (which causes warning in Xcode 16) I've added NS_SWIFT_SENDABLE to other query types as well.

Closes ably#1971

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced the ARTBaseQuery component, enhancing query capabilities within the Ably framework.
    • Added properties to various query classes, allowing for more granular control over query parameters, including start, end, limit, and direction.
    • Enhanced presence query functionality with new properties for improved control over synchronization behavior.
    • Improved handling of statistics queries with a new granularity unit.
    • Added Swift concurrency attributes to ARTChannelOptions and ARTRealtimeChannelOptions for improved interoperability.
  • Bug Fixes

    • Improved immutability checks for query objects to prevent modifications after they are marked as "frozen."
    • Enhanced handling of nil values during encoding and decoding processes to prevent unexpected behavior.
  • Tests

    • Expanded the test suite to include checks for exception handling when modifying frozen query properties, ensuring robustness and reliability.

@ruancomelli
Copy link
Collaborator Author

This is an experiment review for experiment mermaid_diagrams
Run ID: mermaid_diagrams/run_2024-09-26T09-04-23_v1-23-0-20-g8a080be57-dirty
The benchmark review for this pull request can be found at #1.
This pull request was cloned from https://github.com/ably/ably-cocoa/pull/1973. (Note: the URL is not a link to avoid triggering a notification on the original pull request.)

Experiment configuration
review_config:
  # User configuration for the review
  # - benchmark - use the user config from the benchmark reviews
  # - <value> - use the value directly
  user_review_config:
    enable_ai_review: true
    enable_rule_comments: false

    enable_complexity_comments: false
    enable_security_comments: false
    enable_tests_comments: false
    enable_comment_suggestions: false
    enable_functionality_review: false

    enable_pull_request_summary: false
    enable_review_guide: true

    enable_approvals: false

  ai_review_config:
    # The model responses to use for the experiment
    # - benchmark - use the model responses from the benchmark reviews
    # - llm - call the language model to generate responses
    model_responses:
      comments_model: benchmark
      comment_area_model: benchmark
      comment_validation_model: benchmark
      comment_suggestion_model: benchmark
      complexity_model: benchmark
      functionality_model: benchmark
      security_model: benchmark
      tests_model: benchmark
      pull_request_summary_model: benchmark
      review_guide_model: llm
      overall_comments_model: benchmark

# The pull request dataset to run the experiment on
pull_request_dataset:
- https://github.com/sourcery-ai/core/pull/4607
- https://github.com/sourcery-ai/core/pull/4631
- https://github.com/sourcery-ai/core/pull/4647
    # CodeRabbit examples:
- https://github.com/2lambda123/-Orange-OpenSource-oorobot/pull/15
- https://github.com/2lambda123/galaxyproject-galaxy/pull/12
- https://github.com/a0v0/avtoolz/pull/79
- https://github.com/adityask98/Hotaru/pull/10
- https://github.com/agdas/vscode/pull/2
- https://github.com/agluszak/hirschgarten/pull/2
- https://github.com/alexsnow348/insightface/pull/46
- https://github.com/alikuxac/utilities/pull/10
- https://github.com/AlphaDev87/timba-api/pull/49
- https://github.com/AngeloTadeucci/Maple2/pull/239
- https://github.com/AngeloTadeucci/Maple2.File/pull/36
- https://github.com/AngeloTadeucci/Maple2/pull/233
    # Examples where CodeRabbit does not generate diagrams
- https://github.com/baptisteArno/typebot.io/pull/1778
- https://github.com/btipling/foundations/pull/33
- https://github.com/btipling/foundations/pull/31
- https://github.com/chintu-777/jaeger/pull/1
- https://github.com/coji/remix-docs-ja/pull/55
- https://github.com/DaveMBush/SmartNgRX/pull/622
- https://github.com/DaveMBush/SmartNgRX/pull/481
- https://github.com/dkittle/party-connections/pull/6
- https://github.com/Drajad-Kusuma-Adi/onstudy-backend/pull/6
- https://github.com/imaami/libcanth/pull/2
  # Requested by Tim
- https://github.com/2lambda123/-Orange-OpenSource-oorobot/pull/15
- https://github.com/2lambda123/galaxyproject-galaxy/pull/12
- https://github.com/a0v0/avtoolz/pull/79
- https://github.com/adityask98/Hotaru/pull/10
- https://github.com/agdas/vscode/pull/2
- https://github.com/agluszak/hirschgarten/pull/2
- https://github.com/4DNucleome/PartSeg/pull/1183
- https://github.com/ably/ably-cocoa/pull/1973
- https://github.com/ably-labs/ably-chat-swift/pull/54
- https://github.com/ably-labs/ably-chat-swift/pull/35

# Questions to ask to label the review comments
review_comment_labels: []
# - label: correct
#   question: Is this comment correct?

# Benchmark reviews generated by running
#   python -m scripts.experiment benchmark <experiment_name>
benchmark_reviews:
- dataset_pull_request: https://github.com/sourcery-ai/core/pull/4607
  review_pull_request: https://github.com/sourcery-ai-experiments/core/pull/338
- dataset_pull_request: https://github.com/sourcery-ai/core/pull/4631
  review_pull_request: https://github.com/sourcery-ai-experiments/core/pull/339
- dataset_pull_request: https://github.com/sourcery-ai/core/pull/4647
  review_pull_request: https://github.com/sourcery-ai-experiments/core/pull/340
- dataset_pull_request: https://github.com/2lambda123/-Orange-OpenSource-oorobot/pull/15
  review_pull_request: https://github.com/sourcery-ai-experiments/-Orange-OpenSource-oorobot/pull/2
- dataset_pull_request: https://github.com/2lambda123/galaxyproject-galaxy/pull/12
  review_pull_request: https://github.com/sourcery-ai-experiments/galaxyproject-galaxy/pull/1
- dataset_pull_request: https://github.com/adityask98/Hotaru/pull/10
  review_pull_request: https://github.com/sourcery-ai-experiments/Hotaru/pull/2
- dataset_pull_request: https://github.com/agdas/vscode/pull/2
  review_pull_request: https://github.com/sourcery-ai-experiments/vscode/pull/3
- dataset_pull_request: https://github.com/agluszak/hirschgarten/pull/2
  review_pull_request: https://github.com/sourcery-ai-experiments/hirschgarten/pull/2
- dataset_pull_request: https://github.com/alikuxac/utilities/pull/10
  review_pull_request: https://github.com/sourcery-ai-experiments/utilities/pull/2
- dataset_pull_request: https://github.com/AlphaDev87/timba-api/pull/49
  review_pull_request: https://github.com/sourcery-ai-experiments/timba-api/pull/2
- dataset_pull_request: https://github.com/AngeloTadeucci/Maple2/pull/239
  review_pull_request: https://github.com/sourcery-ai-experiments/Maple2/pull/3
- dataset_pull_request: https://github.com/AngeloTadeucci/Maple2.File/pull/36
  review_pull_request: https://github.com/sourcery-ai-experiments/Maple2.File/pull/2
- dataset_pull_request: https://github.com/AngeloTadeucci/Maple2/pull/233
  review_pull_request: https://github.com/sourcery-ai-experiments/Maple2/pull/4
- dataset_pull_request: https://github.com/baptisteArno/typebot.io/pull/1778
  review_pull_request: https://github.com/sourcery-ai-experiments/typebot.io/pull/1
- dataset_pull_request: https://github.com/btipling/foundations/pull/33
  review_pull_request: https://github.com/sourcery-ai-experiments/foundations/pull/1
- dataset_pull_request: https://github.com/btipling/foundations/pull/31
  review_pull_request: https://github.com/sourcery-ai-experiments/foundations/pull/2
- dataset_pull_request: https://github.com/chintu-777/jaeger/pull/1
  review_pull_request: https://github.com/sourcery-ai-experiments/jaeger/pull/1
- dataset_pull_request: https://github.com/coji/remix-docs-ja/pull/55
  review_pull_request: https://github.com/sourcery-ai-experiments/remix-docs-ja/pull/1
- dataset_pull_request: https://github.com/DaveMBush/SmartNgRX/pull/622
  review_pull_request: https://github.com/sourcery-ai-experiments/SmartNgRX/pull/1
- dataset_pull_request: https://github.com/DaveMBush/SmartNgRX/pull/481
  review_pull_request: https://github.com/sourcery-ai-experiments/SmartNgRX/pull/2
- dataset_pull_request: https://github.com/dkittle/party-connections/pull/6
  review_pull_request: https://github.com/sourcery-ai-experiments/party-connections/pull/1
- dataset_pull_request: https://github.com/Drajad-Kusuma-Adi/onstudy-backend/pull/6
  review_pull_request: https://github.com/sourcery-ai-experiments/onstudy-backend/pull/1
- dataset_pull_request: https://github.com/imaami/libcanth/pull/2
  review_pull_request: https://github.com/sourcery-ai-experiments/libcanth/pull/1
- dataset_pull_request: https://github.com/4DNucleome/PartSeg/pull/1183
  review_pull_request: https://github.com/sourcery-ai-experiments/PartSeg/pull/2
- dataset_pull_request: https://github.com/ably/ably-cocoa/pull/1973
  review_pull_request: https://github.com/sourcery-ai-experiments/ably-cocoa/pull/1
- dataset_pull_request: https://github.com/ably-labs/ably-chat-swift/pull/54
  review_pull_request: https://github.com/sourcery-ai-experiments/ably-chat-swift/pull/1
- dataset_pull_request: https://github.com/ably-labs/ably-chat-swift/pull/35
  review_pull_request: https://github.com/sourcery-ai-experiments/ably-chat-swift/pull/2

@SourceryAI
Copy link

SourceryAI commented Sep 26, 2024

Reviewer's Guide by Sourcery

This pull request implements several improvements to the Ably SDK, focusing on enhancing query functionality, improving Swift compatibility, and adding immutability checks. The main changes include:

  1. Adding NS_SWIFT_SENDABLE attribute to various query types for better Swift interoperability.
  2. Implementing a new ARTBaseQuery class to provide common functionality for query objects.
  3. Adding properties and setter methods to query classes (ARTDataQuery, ARTPresenceQuery, ARTRealtimePresenceQuery, ARTStatsQuery) for improved control over query parameters.
  4. Implementing immutability checks to prevent modifications to query objects after they are "frozen".
  5. Updating test cases to verify the new immutability behavior and other changes.
  6. Improving error handling and nil value handling in data encoding and decoding processes.
  7. Adding retroactive conformance to Sequence protocol for ARTRealtimeChannels and ARTRestChannels when the RetroactiveAttribute feature is available.

Sequence Diagrams

Query Class Hierarchy

classDiagram
      ARTBaseQuery <|-- ARTDataQuery
      ARTBaseQuery <|-- ARTPresenceQuery
      ARTDataQuery <|-- ARTRealtimeHistoryQuery
      ARTPresenceQuery <|-- ARTRealtimePresenceQuery
      ARTDataQuery <|-- ARTStatsQuery

      class ARTBaseQuery {
        +frozen: Bool
        +throwIfFrozen()
      }
      class ARTDataQuery {
        +start: NSDate
        +end: NSDate
        +limit: uint16_t
        +direction: ARTQueryDirection
      }
      class ARTPresenceQuery {
        +limit: NSUInteger
        +clientId: NSString
        +connectionId: NSString
      }
      class ARTRealtimeHistoryQuery {
        +untilAttach: Bool
      }
      class ARTRealtimePresenceQuery {
        +waitForSync: Bool
      }
      class ARTStatsQuery {
        +unit: ARTStatsGranularity
      }
Loading

Query Immutability Flow

sequenceDiagram
      participant Client
      participant Query
      participant APIMethod

      Client->>Query: Create query
      Client->>Query: Set properties
      Client->>APIMethod: Pass query to API method
      APIMethod->>Query: Set frozen = true
      Client->>Query: Attempt to modify property
      Query-->>Client: Throw exception (Object inaccessible)
Loading

File-Level Changes

Change Details Files
Implemented ARTBaseQuery class and added properties to query classes
  • Created new ARTBaseQuery class with frozen property and throwIfFrozen method
  • Added properties (start, end, limit, direction) to ARTDataQuery
  • Added properties (limit, clientId, connectionId) to ARTPresenceQuery
  • Added waitForSync property to ARTRealtimePresenceQuery
  • Added unit property to ARTStatsQuery
Source/ARTDataQuery.m
Source/ARTRestPresence.m
Source/ARTRealtimePresence.m
Source/ARTStats.m
Source/ARTBaseQuery.m
Source/include/Ably/ARTBaseQuery.h
Implemented immutability checks for query objects
  • Added throwIfFrozen method calls in setter methods of query classes
  • Set frozen = true when passing query objects to API methods
  • Updated test cases to verify immutability behavior
Source/ARTDataQuery.m
Source/ARTRestPresence.m
Source/ARTRealtimePresence.m
Source/ARTStats.m
Source/ARTRest.m
Source/ARTRestChannel.m
Test/Tests/RestClientPresenceTests.swift
Test/Tests/RestClientChannelTests.swift
Test/Tests/RealtimeClientPresenceTests.swift
Test/Tests/RestClientStatsTests.swift
Added NS_SWIFT_SENDABLE attribute to query and options classes
  • Added NS_SWIFT_SENDABLE to ARTDataQuery, ARTPresenceQuery, ARTRealtimePresenceQuery, ARTStatsQuery
  • Added NS_SWIFT_SENDABLE to ARTChannelOptions, ARTChannelProperties, ARTRealtimeChannelOptions
Source/include/Ably/ARTDataQuery.h
Source/include/Ably/ARTRestPresence.h
Source/include/Ably/ARTRealtimePresence.h
Source/include/Ably/ARTStats.h
Source/include/Ably/ARTChannelOptions.h
Source/include/Ably/ARTRealtimeChannel.h
Source/include/Ably/ARTRealtimeChannelOptions.h
Improved error handling and nil value handling
  • Added nil check for encoded data in ARTDataEncoder
  • Improved error handling in decryption process
Source/ARTDataEncoder.m
Added retroactive conformance to Sequence protocol
  • Added conditional retroactive conformance to Sequence for ARTRealtimeChannels and ARTRestChannels
Test/Tests/RealtimeClientChannelsTests.swift
Test/Tests/RestClientChannelsTests.swift

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@SourceryAI SourceryAI left a comment

Choose a reason for hiding this comment

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

Hey @ruancomelli - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Ensure that the new ARTBaseQuery class is well-documented to clarify its purpose and usage for other developers.
  • Review the test coverage to ensure all edge cases, especially around the new immutability checks, are thoroughly tested.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Documentation: all looks good

LangSmith trace

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@ruancomelli ruancomelli closed this Oct 1, 2024
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.

3 participants