-
-
Notifications
You must be signed in to change notification settings - Fork 413
Open
Labels
Description
Problem Description
This issue tracks two code quality problems identified by CodeScene static analysis in the internal module:
1. String Heavy Function Arguments
- Current state: 48.0% of all arguments to the 32 functions in the internal module are strings
- Threshold exceeded: The recommended threshold is 39.0%
- Impact: This indicates potential overuse of primitive string types where more specific domain types would be more appropriate
2. Primitive Obsession
- Current state: 68.0% of all function arguments are primitive types (string, int, bool, etc.)
- Threshold exceeded: The recommended threshold is 40.0%
- Impact: This is a code smell indicating that the code may benefit from introducing domain-specific types
Why These Issues Should Be Fixed
String Heavy Arguments Problems:
- Type Safety: Strings provide no compile-time validation of content format or constraints
- API Clarity: Function signatures become unclear about what specific type of string is expected
- Runtime Errors: Easy to pass wrong string values (e.g., passing a file path where a directory name is expected)
- Maintainability: Harder to refactor and evolve the API
Primitive Obsession Problems:
- Domain Modeling: Primitives don't express business domain concepts effectively
- Validation: Validation logic gets scattered instead of being encapsulated in types
- Documentation: The code becomes less self-documenting
- Refactoring: Changes to data representation require touching many places
Affected Areas
The issues are concentrated in the src/internal/ module, which contains the core application logic including:
model.go- Main application model with complex state management- File panel operations and management
- UI state handling and rendering
- File system operations
Potential Solutions
- Introduce Domain Types: Replace string parameters with specific types like
FilePath,DirectoryPath,PanelID, etc. - Create Value Objects: For commonly used combinations of primitives
- Use Enums/Constants: For string parameters with limited valid values
- Struct Parameters: Group related parameters into meaningful structs
Context
This issue was identified during PR #973 review. The PR has grown large, so addressing these architectural improvements is being deferred to maintain focus on the primary objectives.
Related PR: #973
Reporter: @lazysegtree