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

RUM-3808 fix: Avoid name collision with Required Reason APIs #1774

Conversation

ncreated
Copy link
Member

@ncreated ncreated commented Apr 11, 2024

What and why?

📦 This PR renames symbols in our codebase to avoid false-positive warnings on using Required Reason APIs. Next to this, it adds basic linter rule to prevent from using names that may result with conflicts.

Related GH Issues: #1749, #1756

How?

Renamed: .creationDate.fileCreationDate and systemUptimegetSystemUptime.

Added custom linter rule that scans the code for Required Reason API names. If found, it raises an error:

Screenshot 2024-04-11 at 18 17 15

The rule is inspired by the text scanner from this repo. It is up to date with the list of Apple APIs.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes

Custom CI job configuration (optional)

  • Run unit tests for Core, RUM, Trace, Logs, CR and WVT
  • Run unit tests for Session Replay
  • Run integration tests
  • Run smoke tests
  • Run tests for tools/

@ncreated ncreated self-assigned this Apr 11, 2024
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Apr 11, 2024

Datadog Report

Branch report: ncreated/RUM-3808/avoid-name-colision-with-required-reason-apis
Commit report: d6b8ee4
Test service: dd-sdk-ios

✅ 0 Failed, 2727 Passed, 0 Skipped, 5m 51.73s Wall Time
🔻 Test Sessions change in coverage: 8 decreased, 5 increased

🔻 Code Coverage Decreases vs Default Branch (8)

This report shows up to 5 code coverage decreases.

  • test DatadogCrashReportingTests tvOS 27.91% (-0.69%) - Details
  • test DatadogCrashReportingTests iOS 27.87% (-0.69%) - Details
  • test DatadogWebViewTrackingTests iOS 17.13% (-0.68%) - Details
  • test DatadogTraceTests iOS 48.78% (-0.41%) - Details
  • test DatadogTraceTests tvOS 48.84% (-0.4%) - Details

@ncreated ncreated marked this pull request as ready for review April 11, 2024 16:21
@ncreated ncreated requested review from a team as code owners April 11, 2024 16:21
private var userDefaults: UserDefaults
private var userDefaults: UserDefaults // swiftlint:disable:this required_reason_api_name
Copy link
Member Author

Choose a reason for hiding this comment

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

💡 This is true positive - UserDefaults is the only Required Reason API we use. It is declared in our manifest.

Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

Thanks!!

@@ -89,6 +89,61 @@ custom_rules:
- doccomment
message: "`UIApplication.shared` is unavailable in some environments. Check `UIApplication.managedShared`."
severity: error
required_reason_api_name: # prevents from declaring symbols that may conflict with Apple's Required Reason APIs
Copy link
Member

Choose a reason for hiding this comment

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

perfect!

Copy link
Member

@maciejburda maciejburda left a comment

Choose a reason for hiding this comment

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

Nice!

@ncreated ncreated merged commit 34d8fbd into develop Apr 12, 2024
6 checks passed
@ncreated ncreated deleted the ncreated/RUM-3808/avoid-name-colision-with-required-reason-apis branch April 12, 2024 09:42
This was referenced Apr 16, 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