Skip to content

POC: deduplicate dry4swift findings#618

Draft
marandaneto wants to merge 1 commit into
mainfrom
refactor/dry4swift-poc-dedupe
Draft

POC: deduplicate dry4swift findings#618
marandaneto wants to merge 1 commit into
mainfrom
refactor/dry4swift-poc-dedupe

Conversation

@marandaneto
Copy link
Copy Markdown
Member

💡 Motivation and Context

POC for using dry4swift to identify structural duplicate Swift code and apply low-risk deduplication in the iOS SDK.

This PR intentionally focuses on mechanical/refactor-only changes where shared helpers reduce duplicate implementation patterns without changing public behavior.

Key examples:

  • shared integration install/uninstall state handling
  • shared survey enum string decoding helper
  • shared remote-config cached value/dictionary helpers
  • shared SDK helpers for autocapture/rageclick, feature events, and exception capture
  • shared URLSession request execution and a few small replay/survey UI helpers

The initial dry4swift candidate count was reduced from 203 to 120 after the POC refactors.

💚 How did you test it?

  • make format
  • make test — 559 tests passed
  • Re-ran dry4swift locally to compare duplicate candidate counts

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

@marandaneto
Copy link
Copy Markdown
Member Author

@github-actions
Copy link
Copy Markdown
Contributor

posthog-ios Compliance Report

Date: 2026-05-27 15:56:54 UTC
Duration: 4553ms

⚠️ Some Tests Failed

1/16 tests passed, 15 failed


Feature_Flags Tests

⚠️ 1/16 tests passed, 15 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 106ms
Request Payload.Flags Request Uses V2 Query Param 150ms
Request Payload.Flags Request Hits Flags Path Not Decide 147ms
Request Payload.Flags Request Omits Authorization Header 126ms
Request Payload.Token In Flags Body Matches Init 97ms
Request Payload.Groups Round Trip 77ms
Request Payload.Groups Default To Empty Object 111ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 106ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 102ms
Request Payload.Disable Geoip Omitted Defaults To False 111ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 100ms
Request Lifecycle.No Flags Request On Init Alone 62ms
Request Lifecycle.No Flags Request On Normal Capture 2239ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 122ms
Request Lifecycle.Mock Response Value Is Returned To Caller 112ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 116ms

Failures

request_payload.request_with_person_properties_device_id

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.flags_request_uses_v2_query_param

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.flags_request_hits_flags_path_not_decide

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.flags_request_omits_authorization_header

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.token_in_flags_body_matches_init

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.groups_round_trip

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.groups_default_to_empty_object

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.person_properties_distinct_id_auto_populated_when_caller_omits_it

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.disable_geoip_false_propagates_as_geoip_disable_false

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.disable_geoip_omitted_defaults_to_false

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_payload.flag_keys_to_evaluate_contains_only_requested_key

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_lifecycle.no_flags_request_on_normal_capture

Expected 0 /flags requests, got 2

request_lifecycle.two_flag_calls_produce_two_remote_requests

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

request_lifecycle.mock_response_value_is_returned_to_caller

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

side_effect_events.get_feature_flag_captures_feature_flag_called_event

404, message='Not Found', url='http://host.docker.internal:8080/get_feature_flag'

@marandaneto
Copy link
Copy Markdown
Member Author

@ioannisj @turnipdabeets wdyt? this could be in CI as well

@ioannisj
Copy link
Copy Markdown
Contributor

@ioannisj @turnipdabeets wdyt? this could be in CI as well

Had me at installIfNeeded()

@ioannisj
Copy link
Copy Markdown
Contributor

No familiar at all with dry4swift and can't find it online? Is this under github.com/dryproject?

@marandaneto
Copy link
Copy Markdown
Member Author

marandaneto commented May 29, 2026

dry4swift

https://github.com/marandaneto/dry4swift

i have made a similar pr for python PostHog/posthog-python#623

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