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

Enable explicit_init lint rule and fix issues #3418

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

MarkVillacampa
Copy link
Member

This rule will warn when calling init with the explicit type where it can be inferred, or where the .init part can be omitted.

@MarkVillacampa MarkVillacampa added the style Changes that don't affect the meaning of the code (white-space, formatting, missing semi-colons, etc label Nov 15, 2023
Copy link
Contributor

@NachoSoto NachoSoto left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! 👏🏻

@@ -75,7 +75,7 @@ private extension StoreProductDiscount.PaymentMode {
case .freeTrial:
self = .freeTrial
@unknown default:
Logger.appleWarning(Strings.storeKit.skunknown_payment_mode(String.init(describing: paymentMode)))
Logger.appleWarning(Strings.storeKit.skunknown_payment_mode(.init(describing: paymentMode)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do

Suggested change
Logger.appleWarning(Strings.storeKit.skunknown_payment_mode(.init(describing: paymentMode)))
Logger.appleWarning(Strings.storeKit.skunknown_payment_mode(paymentMode.rawValue))

That doesn't use reflection so it's a lot faster

Copy link
Member Author

@MarkVillacampa MarkVillacampa Nov 15, 2023

Choose a reason for hiding this comment

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

Sadly it's a UInt enum :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Then String(enum.rawValue). Describing uses runtime reflection and it's A LOT slower.

Copy link
Contributor

Choose a reason for hiding this comment

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

You already merged so it's fine. It was already like this anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

And it's not like this is a hot path.

@@ -60,7 +60,7 @@ private extension StoreProductDiscount.PaymentMode {
case .freeTrial:
self = .freeTrial
default:
Logger.appleWarning(Strings.storeKit.skunknown_payment_mode(String.init(describing: paymentMode)))
Logger.appleWarning(Strings.storeKit.skunknown_payment_mode(.init(describing: paymentMode)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (330e97c) 86.07% compared to head (52ecc8c) 86.07%.

Files Patch % Lines
...StoreKitAbstractions/SK1StoreProductDiscount.swift 0.00% 1 Missing ⚠️
...StoreKitAbstractions/SK2StoreProductDiscount.swift 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3418   +/-   ##
=======================================
  Coverage   86.07%   86.07%           
=======================================
  Files         237      237           
  Lines       17201    17201           
=======================================
  Hits        14805    14805           
  Misses       2396     2396           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MarkVillacampa MarkVillacampa merged commit 679767a into main Nov 15, 2023
21 checks passed
@MarkVillacampa MarkVillacampa deleted the lint-explicit-init branch November 15, 2023 23:20
tonidero pushed a commit that referenced this pull request Nov 30, 2023
**This is an automatic release.**

### RevenueCatUI
* Paywalls: Fix navigation with close button in UIKit (#3466) via Andy
Boedo (@aboedo)
* `Paywalls`: `watchOS` support (#3291) via NachoSoto (@NachoSoto)
### Dependency Updates
* Bump cocoapods from 1.14.2 to 1.14.3 (#3464) via dependabot[bot]
(@dependabot[bot])
* Bump fastlane from 2.216.0 to 2.217.0 (#3415) via dependabot[bot]
(@dependabot[bot])
* Bump danger from 9.3.2 to 9.4.0 (#3414) via dependabot[bot]
(@dependabot[bot])
### Other Changes
* Some `APITester` fixes (#3444) via NachoSoto (@NachoSoto)
* `HTTPClient`: test all request headers (#3425) via NachoSoto
(@NachoSoto)
* `CircleCI`: fix snapshot generation for iOS 14 (#3431) via NachoSoto
(@NachoSoto)
* Remove `MockStoreMessagesHelper` from SDK (#3417) via NachoSoto
(@NachoSoto)
* Enable explicit_init lint rule and fix issues (#3418) via Mark
Villacampa (@MarkVillacampa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style Changes that don't affect the meaning of the code (white-space, formatting, missing semi-colons, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants