Feature/more consistent stdout #66
No reviewers
Labels
No labels
bug
ci
documentation
duplicate
enhancement
feature
good first issue
help wanted
invalid
performance
priority
P0
priority
P1
priority
P2
question
refactor
size
L
size
M
size
S
size
XL
size
XS
tests
trivial
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
noe.trevino/paso!66
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/more-consistent-stdout"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -105,6 +105,6 @@ func runDelete(cmd *cobra.Command, args []string) error {})}DRY violation:
cli.GetColorScheme()is called repeatedly in every file. This pattern is repeated across 13 different files in this PR. Consider extracting this into a helper function or method on the CLI instance to eliminate this duplication.Example refactoring:
Then each call site becomes:
This would eliminate ~26 lines of duplicate
colorScheme := cli.GetColorScheme()declarations.The
colorSchemevariable is declared once at line 104, but then the same pattern appears in multiple functions (lines 146, 193, 229). This is a DRY violation at the file level - each function independently fetches the color scheme.Consider passing
colorSchemeas a parameter toaddHookCommandandremoveHookCommandat the function signature level, or better yet, use the helper method pattern suggested in other comments.PR Summary (auto-generated)
styles.RenderSuccess()andstyles.RenderSuccessWithDetails()functions from theinternal/cli/stylespackagefmt.Printf("✓ ...")patterns with standardized rendering that respects the user's color scheme configurationinternal/cli/styles/success_test.gocovering all five color schemes (default, monochrome, wave, dragon, lotus) with 273 test casescolorSchemeparameter for consistent styling throughout the application@ -202,3 +203,4 @@cli.PrintSuccess("Claude hooks removed")return nil}The signature now includes
colorSchemeparameter, but this is being fetched in the calling function. This creates tight coupling and forces every caller to know about color schemes.Better approach: Have
addHookCommandcallcli.GetColorScheme()internally if it needs to print, or use a dedicated method on CLI for printing success messages.Guard pattern violation: The boolean return value from
addHookCommandis used to conditionally print. This creates nested logic.Refactor to early return pattern:
Or better, have
addHookCommandhandle its own output internally rather than returning a boolean for conditional printing.@ -96,9 +97,9 @@ func runAdd(cmd *cobra.Command, args []string) error {}Same pattern of fetching
colorSchemeand callingstyles.RenderSuccesswithfmt.Sprintf. This exact pattern appears in both branches (lines 102 and 104) and throughout the entire PR.The duplication extends to:
cli.GetColorScheme()callfmt.Print()wrappingstyles.RenderSuccess()callfmt.Sprintf()for string formattingAll of these could be consolidated into a single helper method.
@ -132,9 +132,9 @@ func assignTask(cmd *cobra.Command, cliInstance *cli.CLI, taskID int, assigneeID}Another instance of the same repetitive pattern. This file has the exact same structure:
fmt.Sprintfstyles.RenderSuccessThis pattern is repeated across 13 files with ~26 occurrences total in this PR.
Code Review Summary
This PR successfully standardizes stdout formatting across the codebase with comprehensive test coverage. However, there are significant code quality issues that need to be addressed:
Critical Issues
1. Severe DRY Violation (High Priority)
The pattern of fetching color scheme and rendering success messages is duplicated ~26 times across 13 files:
Impact:
Recommended Fix:
Create helper methods on the CLI instance:
This would reduce each call site to:
2. Guard Pattern Violations
Multiple locations have unnecessary nesting that could be flattened:
claude.go:107-113 - Boolean return used for conditional printing instead of having the function handle its own output
opencode.go:98 - Color scheme fetched before early return check, wasting cycles when plugin already installed
3. Tight Coupling in Function Signatures
claude.go:215 and claude.go:261 - Functions now require
colorSchemeparameter, forcing all callers to know about color schemes. This violates the Single Responsibility Principle - these functions should handle their own presentation concerns.Test Coverage
The comprehensive golden file test suite (273 lines) is well-structured and provides good coverage across all color schemes.
Files with Issues
Most critical files needing refactoring:
internal/cli/assignee/delete.gointernal/cli/assignee/set.gointernal/cli/db/add.gointernal/cli/db/connect.gointernal/cli/db/remove.gointernal/cli/setup/claude.gointernal/cli/setup/opencode.gointernal/cli/task/assign.gointernal/cli/task/estimate.gointernal/cli/project/git_link.gointernal/cli/project/git_unlink.goRecommendation
Before merging, extract the duplicated pattern into helper methods. This is a straightforward refactoring that will significantly improve maintainability.