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

Refactor FXIOS-10205 [Swiftlint] Resolve 1 implicitly_unwrapped_optional violations in BottomSheetViewController #23795

Merged

Conversation

tonell-m
Copy link
Contributor

📜 Tickets

Jira ticket
Github issue

💡 Description

Continuing resolving implicitly_unwrapped_optional violations in order to enable the rule for further developments.

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

@tonell-m tonell-m requested a review from a team as a code owner December 17, 2024 13:55
@tonell-m tonell-m requested a review from Cramsden December 17, 2024 13:55
@tonell-m tonell-m changed the title Refactor FXIOS-10205 - Resolve 3 implicitly_unwrapped_optional violations in BottomSheetViewController Refactor FXIOS-10205 - Resolve 1 implicitly_unwrapped_optional violations in BottomSheetViewController Dec 17, 2024
Copy link
Contributor

@Cramsden Cramsden left a comment

Choose a reason for hiding this comment

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

Hi 👋 Thank you so much for this contribution! This code looks good to me I just had one small question. Thanks again for your help.

Comment on lines 178 to 179
let contentViewBottomConstraint = sheetView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
self.contentViewBottomConstraint = contentViewBottomConstraint
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change needed as part of the unwrapped optional change? Couldn't we continue to set the classes property directly without needing to create an intermediate property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi 👋

This property is then used in NSLayoutContraints.activate([...]), so there is two possible approaches here, either use an intermediate property like this that will be non optional, or assign the property directly and right after add a guard let statement to safely unwrap the property before using it in the constraints array, which seemed a bit awkward to me for a property that is just initialized here.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see. That makes sense!

Copy link
Contributor Author

@tonell-m tonell-m Dec 18, 2024

Choose a reason for hiding this comment

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

Hi @Cramsden, as suggested by @PARAIPAN9 in #23833 it's actually more consistent with the rest of the codebase to just activate the newly created constraint in place after initialising it as a class property instead of using a temporary local property, see the latest commit for details.

@lmarceau lmarceau changed the title Refactor FXIOS-10205 - Resolve 1 implicitly_unwrapped_optional violations in BottomSheetViewController Refactor FXIOS-10205 [Swiftlint] Resolve 1 implicitly_unwrapped_optional violations in BottomSheetViewController Dec 17, 2024
@mobiletest-ci-bot
Copy link

Messages
📖 Project coverage: 34.02%
📖 Edited 1 files
📖 Created 0 files

ComponentLibrary: Coverage: 32.33

File Coverage
BottomSheetViewController.swift 5.56% ⚠️

Generated by 🚫 Danger Swift against ad250b0

Copy link
Collaborator

@PARAIPAN9 PARAIPAN9 left a comment

Choose a reason for hiding this comment

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

@tonell-m, great job and thanks for addressing the change!!

@PARAIPAN9 PARAIPAN9 merged commit b044306 into mozilla-mobile:main Dec 30, 2024
13 checks passed
MattLichtenstein pushed a commit that referenced this pull request Dec 31, 2024
…nal violations in BottomSheetViewController (#23795)

* Resolve warnings in BottomSheetViewController

* Initialise and activate constraint in place

---------

Co-authored-by: Marceau Tonelli <[email protected]>
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.

5 participants