Remove unnecessary comments from codebase
Clean up obvious and redundant comments that don't add value: - Remove step-by-step comments in command handlers - Remove obvious test setup comments - Keep only meaningful comments that explain why, not what
This commit is contained in:
@@ -30,28 +30,23 @@ func NewUpdateHabitHandler(habitRepo repositories.HabitRepository) *UpdateHabitH
|
||||
}
|
||||
|
||||
func (h *UpdateHabitHandler) Handle(ctx context.Context, cmd UpdateHabitCommand) error {
|
||||
// Validate input
|
||||
if strings.TrimSpace(cmd.Name) == "" {
|
||||
return errors.ErrInvalidInput
|
||||
}
|
||||
|
||||
// Find existing habit
|
||||
habit, err := h.habitRepo.FindByID(ctx, cmd.HabitID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check ownership
|
||||
if habit.UserID != cmd.UserID {
|
||||
return errors.ErrUnauthorized
|
||||
}
|
||||
|
||||
// Cannot update archived habits
|
||||
if !habit.IsActive() {
|
||||
return errors.ErrInvalidInput
|
||||
}
|
||||
|
||||
// Update fields
|
||||
habit.Name = cmd.Name
|
||||
habit.Description = cmd.Description
|
||||
habit.CarryOver = cmd.CarryOver
|
||||
@@ -59,6 +54,5 @@ func (h *UpdateHabitHandler) Handle(ctx context.Context, cmd UpdateHabitCommand)
|
||||
habit.SpecificDays = cmd.SpecificDays
|
||||
habit.SpecificDates = cmd.SpecificDates
|
||||
|
||||
// Save changes
|
||||
return h.habitRepo.Update(ctx, habit)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user