Skip to content

Enable explicit_init lint rule and fix issues#3418

Merged
MarkVillacampa merged 1 commit into
mainfrom
lint-explicit-init
Nov 15, 2023
Merged

Enable explicit_init lint rule and fix issues#3418
MarkVillacampa merged 1 commit into
mainfrom
lint-explicit-init

Conversation

@MarkVillacampa

Copy link
Copy Markdown
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.

@NachoSoto NachoSoto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for doing this! 👏🏻

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

@MarkVillacampa MarkVillacampa Nov 15, 2023

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto

@codecov

codecov Bot commented Nov 15, 2023

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.07%. Comparing base (330e97c) to head (52ecc8c).
Report is 438 commits behind head on main.

Files with missing lines 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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants