Skip to content

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

ionixjunior
Copy link
Contributor

📜 Tickets

Jira ticket
Github issue

💡 Description

This PR removes 2 closure_body_length violations from the MainMenuMiddleware.swift (Firefox) and InternalTelemetrySettingsView.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 the mainMenuProvider property, splitting it into separated functions. I created three new functions, each one based on the ActionType: MainMenuActionType, GeneralBrowserActionType, and MainMenuDetailsActionType. 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

  • 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)

@ionixjunior ionixjunior requested a review from a team as a code owner April 22, 2025 22:23
@ionixjunior ionixjunior requested a review from lmarceau April 22, 2025 22:23
Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni left a 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 }
Copy link
Collaborator

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 😃

@lmarceau lmarceau removed their request for review April 24, 2025 13:29
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.

2 participants