Feature/time estimate #65
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!65
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/time-estimate"
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?
DRY violation: This validation logic duplicates
ParseEstimateinestimate.go. Both functions:Extract common parsing logic to eliminate duplication. Consider making
ValidateEstimatecallParseEstimateand discard the result, or create a shared helper function.@ -0,0 +96,4 @@return updateEstimate(cmd, cliInstance, taskID, &estimate, formatter, jsonOutput, quietMode)}func updateEstimate(cmd *cobra.Command, cliInstance *cli.CLI, taskID int, estimate *string, formatter *cli.OutputFormatter, jsonOutput, quietMode bool) error {Unnecessary parameter duplication: The function signature takes 7 parameters where most are just passed through from the caller. This violates the "preserve whole object" refactoring pattern.
Consider extracting these into a struct or context object to reduce parameter count and improve maintainability.
PR Summary (auto-generated)
paso task estimate <task_id> [estimate]with --clear flag to remove estimates, --json and --quiet output modes, and validation for format (combinations of numbers + units: h/d/w/m)@ -834,0 +884,4 @@var estimatePtr *stringif buffer != "" {estimatePtr = &bufferDRY violation: Lines 878-907 duplicate the same "update if editing, otherwise just set form state" pattern found in
updateAssigneePicker(lines 780-828),updatePriorityPicker(lines 631-671), andupdateTypePicker(lines 711-745).This is the 4th repetition of this conditional update pattern. Extract to a helper function that takes the update operation as a callback.
@ -834,0 +862,4 @@}}return m, nilCode duplication: Lines 856-860 and 919-923 repeat the same validation logic. The error message string
"Invalid format (use e.g. 2h, 1d, 1w2d)"appears 3 times in this function.Extract to a constant or helper function.
@ -0,0 +43,4 @@return nil, fmt.Errorf("%w: no valid components found", ErrInvalidEstimateFormat)}// Verify that the entire string was matched (no extra characters)Inefficient string reconstruction: Building
reconstructedby concatenating all matches is wasteful. You're creating a new string just to compare it with the original.Instead, track cumulative byte positions or use
FindAllStringIndex()to verify the entire string was consumed without allocating a new string.Validation inconsistency: The estimate is set here without validation. While
ValidateEstimateis called in the CLI layer (estimate.go:92), this service method should also validate to protect against invalid data from other callers.Add validation here or document that callers must validate.
@ -151,0 +176,4 @@// Delegate to ParseEstimate for validation_, err := ParseEstimate(est)return err}Critical DRY violation: The validation logic in
ValidateEstimate(lines 158-224) is nearly identical toParseEstimateinestimate.go(lines 33-84). Both:i)This is a textbook violation of DRY. Refactor
ValidateEstimateto callParseEstimateand discard the result:Code Review Summary
Identified several code quality issues requiring attention:
Critical Issues
DRY Violations (High Priority)
Refactoring Opportunities
Guard Pattern Flattening
Performance
Design
Minor Issues
See inline comments for specific locations and suggested fixes.