fix(lint): remove unused funcs, reduce cyclomatic complexity
- Remove unused wrapEventWithDays and printCalendarEvent functions - Extract printEventAttendees and printEventReminders helpers to reduce printCalendarEventWithTimezone complexity from 51 to ~40 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e4207579ad
commit
cb9b240863
@ -17,10 +17,6 @@ type eventWithDays struct {
|
||||
EndLocal string `json:"endLocal,omitempty"`
|
||||
}
|
||||
|
||||
func wrapEventWithDays(event *calendar.Event) *eventWithDays {
|
||||
return wrapEventWithDaysWithTimezone(event, "", nil)
|
||||
}
|
||||
|
||||
func wrapEventsWithDays(events []*calendar.Event) []*eventWithDays {
|
||||
if len(events) == 0 {
|
||||
return []*eventWithDays{}
|
||||
|
||||
@ -10,10 +10,6 @@ import (
|
||||
"github.com/steipete/gogcli/internal/ui"
|
||||
)
|
||||
|
||||
func printCalendarEvent(u *ui.UI, event *calendar.Event) {
|
||||
printCalendarEventWithTimezone(u, event, "", nil)
|
||||
}
|
||||
|
||||
func printCalendarEventWithTimezone(u *ui.UI, event *calendar.Event, calendarTimezone string, loc *time.Location) {
|
||||
if u == nil || event == nil {
|
||||
return
|
||||
@ -63,18 +59,7 @@ func printCalendarEventWithTimezone(u *ui.UI, event *calendar.Event, calendarTim
|
||||
if event.Transparency == "transparent" {
|
||||
u.Out().Printf("show-as\tfree")
|
||||
}
|
||||
if len(event.Attendees) > 0 {
|
||||
for _, a := range event.Attendees {
|
||||
if a == nil || strings.TrimSpace(a.Email) == "" {
|
||||
continue
|
||||
}
|
||||
status := a.ResponseStatus
|
||||
if a.Optional {
|
||||
status += " (optional)"
|
||||
}
|
||||
u.Out().Printf("attendee\t%s\t%s", strings.TrimSpace(a.Email), status)
|
||||
}
|
||||
}
|
||||
printEventAttendees(u, event.Attendees)
|
||||
if event.GuestsCanInviteOthers != nil && !*event.GuestsCanInviteOthers {
|
||||
u.Out().Printf("guests-can-invite\tfalse")
|
||||
}
|
||||
@ -97,19 +82,7 @@ func printCalendarEventWithTimezone(u *ui.UI, event *calendar.Event, calendarTim
|
||||
if len(event.Recurrence) > 0 {
|
||||
u.Out().Printf("recurrence\t%s", strings.Join(event.Recurrence, "; "))
|
||||
}
|
||||
if event.Reminders != nil {
|
||||
if event.Reminders.UseDefault {
|
||||
u.Out().Printf("reminders\t(calendar default)")
|
||||
} else if len(event.Reminders.Overrides) > 0 {
|
||||
reminders := make([]string, 0, len(event.Reminders.Overrides))
|
||||
for _, r := range event.Reminders.Overrides {
|
||||
if r != nil {
|
||||
reminders = append(reminders, fmt.Sprintf("%s:%dm", r.Method, r.Minutes))
|
||||
}
|
||||
}
|
||||
u.Out().Printf("reminders\t%s", strings.Join(reminders, ", "))
|
||||
}
|
||||
}
|
||||
printEventReminders(u, event.Reminders)
|
||||
if len(event.Attachments) > 0 {
|
||||
for _, a := range event.Attachments {
|
||||
if a != nil {
|
||||
@ -206,3 +179,35 @@ func orEmpty(s string, fallback string) string {
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func printEventAttendees(u *ui.UI, attendees []*calendar.EventAttendee) {
|
||||
for _, a := range attendees {
|
||||
if a == nil || strings.TrimSpace(a.Email) == "" {
|
||||
continue
|
||||
}
|
||||
status := a.ResponseStatus
|
||||
if a.Optional {
|
||||
status += " (optional)"
|
||||
}
|
||||
u.Out().Printf("attendee\t%s\t%s", strings.TrimSpace(a.Email), status)
|
||||
}
|
||||
}
|
||||
|
||||
func printEventReminders(u *ui.UI, reminders *calendar.EventReminders) {
|
||||
if reminders == nil {
|
||||
return
|
||||
}
|
||||
if reminders.UseDefault {
|
||||
u.Out().Printf("reminders\t(calendar default)")
|
||||
return
|
||||
}
|
||||
if len(reminders.Overrides) > 0 {
|
||||
parts := make([]string, 0, len(reminders.Overrides))
|
||||
for _, r := range reminders.Overrides {
|
||||
if r != nil {
|
||||
parts = append(parts, fmt.Sprintf("%s:%dm", r.Method, r.Minutes))
|
||||
}
|
||||
}
|
||||
u.Out().Printf("reminders\t%s", strings.Join(parts, ", "))
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user