-
Notifications
You must be signed in to change notification settings - Fork 3k
Refactor FXIOS-7301 - Remove 2 closure_body_length violations from MainMenuMiddleware.swift (Firefox) and InternalTelemetrySettingsView.swift (Focus) #26242
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit refactor for MainMenuMiddleware
the rest looks good to me
switch action.actionType { | ||
case MainMenuActionType.tapNavigateToDestination: | ||
self.handleTapNavigateToDestinationAction(action: action, isHomepage: isHomepage) | ||
if self.handleMainMenuActionType(action: action, isHomepage: isHomepage) { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we change this to instead of checking if the method handles the action, to check for the action type, like we did in other cases.
if let action = action as? GeneralBrowserAction {
handleGeneralBrowserAction()
}
With this we can avoid also returning a boolean to check if the action was handled. What do you think @ionixjunior let me know if it makes sense what i said, thanks 😃
📜 Tickets
Jira ticket
Github issue
💡 Description
This PR removes 2
closure_body_length
violations from theMainMenuMiddleware.swift
(Firefox) andInternalTelemetrySettingsView.swift
(Focus). Also, it decreases the threshold to 42.The most controversial change in this PR is in the
MainMenuMiddleware.swift
file. In this file, I changed themainMenuProvider
property, splitting it into separated functions. I created three new functions, each one based on theActionType
:MainMenuActionType
,GeneralBrowserActionType
, andMainMenuDetailsActionType
. To the last one, I needed to add the@unknown
keyword, because all option already available into switch case statement.Please, feel free to give me suggestions about how can we improve this.
This PR is part of a series of PRs described here #16442 (comment) and here #16442 (comment).
📝 Checklist
You have to check all boxes before merging
@Mergifyio backport release/v120
)