refactor: simplify complex methods and improve code quality#8
Merged
Conversation
- Extract NewMissionContent into focused sub-components: * InputModeSelector for mode switching UI * InputContentSection for content rendering logic * ActionButtonsSection for mission execution controls * Remove @Suppress("CyclomaticComplexMethod") annotation - Refactor MissionResultCard complexity: * Extract MissionStatusRow for status display logic * Extract ExpandableInputSection for collapsible input display * Remove @Suppress("CyclomaticComplexMethod") annotation - Optimize NewMissionViewModel architecture: * Extract StateManager for UI state operations * Extract FieldUpdateHandler for form field updates * Extract ValidationHandler for input validation logic * Extract MissionExecutor for business logic execution * Reduce ViewModel to focused public interface * Add targeted @Suppress with clear justification - Benefits: * Better SOLID principle adherence * Enhanced separation of concerns * Improved testability through delegation * Cleaner preparation for multi-module architecture * All detekt complexity issues resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request focuses on significant refactoring efforts across
NewMissionContent,MissionResultCard, andNewMissionViewModelto address code complexity, improve maintainability, and enhance adherence to code quality standards, primarily driven by Detekt findings.Key Changes:
1.
NewMissionContentRefactoring:InputModeSelector: Manages the UI for switching between input modes.InputContentSection: Handles the rendering logic for different input content (JSON/Manual).ActionButtonsSection: Encapsulates the mission execution buttons and related controls.@Suppress("CyclomaticComplexMethod")annotation as the complexity has been resolved through decomposition.2.
MissionResultCardSimplification:MissionResultCardcomposable for better clarity and reduced complexity:MissionStatusRow: Dedicated to displaying the mission status (success/failure) and rover position/orientation.ExpandableInputSection: Manages the display of collapsible input data within the result card.@Suppress("CyclomaticComplexMethod")annotation due to successful refactoring.3.
NewMissionViewModelArchitecture Optimization:StateManager: Manages UI state updates, message clearing, and input mode switching.FieldUpdateHandler: Handles updates to all form field inputs (JSON, plateau dimensions, rover commands).ValidationHandler: Encapsulates all input validation logic.MissionExecutor: Contains the core business logic for executing rover missions (both network and local).NewMissionViewModel, reducing it to a more focused public interface that coordinates these helper classes.@Suppress("TooManyFunctions")to the ViewModel with a clear justification, as its role is now primarily delegation, which is an acceptable pattern.Benefits & Impact:
CyclomaticComplexMethodissues and generally made the codebase easier to understand and maintain.Testing: