mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Clean up a bunch of if statements based on govet results
This commit is contained in:
parent
1f27cf5b00
commit
72c192cabf
@ -15,9 +15,9 @@ type ChecklistItem struct {
|
||||
func (item *ChecklistItem) CheckMark() string {
|
||||
if item.Checked {
|
||||
return wtf.Config.UString("wtf.mods.todo.checkedIcon", "x")
|
||||
} else {
|
||||
return " "
|
||||
}
|
||||
|
||||
return " "
|
||||
}
|
||||
|
||||
// Toggle changes the checked state of the ChecklistItem
|
||||
|
@ -45,9 +45,9 @@ func (widget *Widget) String() string {
|
||||
|
||||
if args != "" {
|
||||
return fmt.Sprintf(" %s %s ", widget.cmd, args)
|
||||
} else {
|
||||
return fmt.Sprintf(" %s ", widget.cmd)
|
||||
}
|
||||
|
||||
return fmt.Sprintf(" %s ", widget.cmd)
|
||||
}
|
||||
|
||||
func (widget *Widget) execute() {
|
||||
|
@ -50,9 +50,9 @@ func (calEvent *CalEvent) Past() bool {
|
||||
if calEvent.AllDay() {
|
||||
// FIXME: This should calculate properly
|
||||
return false
|
||||
} else {
|
||||
return (calEvent.Now() == false) && calEvent.Start().Before(time.Now())
|
||||
}
|
||||
|
||||
return (calEvent.Now() == false) && calEvent.Start().Before(time.Now())
|
||||
}
|
||||
|
||||
func (calEvent *CalEvent) ResponseFor(email string) string {
|
||||
@ -97,8 +97,8 @@ func (calEvent *CalEvent) Timestamp() string {
|
||||
if calEvent.AllDay() {
|
||||
startTime, _ := time.Parse("2006-01-02", calEvent.event.Start.Date)
|
||||
return startTime.Format(wtf.FriendlyDateFormat)
|
||||
} else {
|
||||
startTime, _ := time.Parse(time.RFC3339, calEvent.event.Start.DateTime)
|
||||
return startTime.Format(wtf.MinimumTimeFormat)
|
||||
}
|
||||
|
||||
startTime, _ := time.Parse(time.RFC3339, calEvent.event.Start.DateTime)
|
||||
return startTime.Format(wtf.MinimumTimeFormat)
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ func Fetch() ([]*CalEvent, error) {
|
||||
timeDateChooser := func(event *calendar.Event) (time.Time, error) {
|
||||
if len(event.Start.Date) > 0 {
|
||||
return time.Parse("2006-01-02", event.Start.Date)
|
||||
} else {
|
||||
return time.Parse(time.RFC3339, event.Start.DateTime)
|
||||
}
|
||||
|
||||
return time.Parse(time.RFC3339, event.Start.DateTime)
|
||||
}
|
||||
|
||||
sort.Slice(events.Items, func(i, j int) bool {
|
||||
|
@ -109,9 +109,9 @@ func (widget *Widget) dayDivider(event, prevEvent *CalEvent) string {
|
||||
func (widget *Widget) descriptionColor(calEvent *CalEvent) string {
|
||||
if calEvent.Past() {
|
||||
return wtf.Config.UString("wtf.mods.gcal.colors.past", "gray")
|
||||
} else {
|
||||
return wtf.Config.UString("wtf.mods.gcal.colors.description", "white")
|
||||
}
|
||||
|
||||
return wtf.Config.UString("wtf.mods.gcal.colors.description", "white")
|
||||
}
|
||||
|
||||
func (widget *Widget) eventSummary(calEvent *CalEvent, conflict bool) string {
|
||||
@ -127,9 +127,9 @@ func (widget *Widget) eventSummary(calEvent *CalEvent, conflict bool) string {
|
||||
|
||||
if conflict {
|
||||
return fmt.Sprintf("%s %s", wtf.Config.UString("wtf.mods.gcal.conflictIcon", "🚨"), summary)
|
||||
} else {
|
||||
return summary
|
||||
}
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
// timeUntil returns the number of hours or days until the event
|
||||
|
@ -52,7 +52,7 @@ func dnsMacOS() []string {
|
||||
|
||||
if len(lines) > 0 {
|
||||
return lines
|
||||
} else {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
return []string{}
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ func wifiNameMacOS() string {
|
||||
func matchStr(data [][]string) string {
|
||||
if len(data) <= 1 {
|
||||
return ""
|
||||
} else {
|
||||
return data[1][1]
|
||||
}
|
||||
|
||||
return data[1][1]
|
||||
}
|
||||
|
||||
//Windows
|
||||
|
@ -48,9 +48,10 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
func (widget *Widget) prettyDate() string {
|
||||
str, err := time.Parse(wtf.TimestampFormat, widget.Date)
|
||||
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
} else {
|
||||
return str.Format("Jan _2, 15:04")
|
||||
}
|
||||
|
||||
return str.Format("Jan _2, 15:04")
|
||||
}
|
||||
|
@ -425,9 +425,9 @@ func ASCIItoTviewColors(text string) string {
|
||||
func colorFor(label string) tcell.Color {
|
||||
if _, ok := colors[label]; ok {
|
||||
return colors[label]
|
||||
} else {
|
||||
return tcell.ColorGreen
|
||||
}
|
||||
|
||||
return tcell.ColorGreen
|
||||
}
|
||||
|
||||
func replaceWithHexColorString(substring string) string {
|
||||
|
@ -7,9 +7,9 @@ import (
|
||||
type FocusState int
|
||||
|
||||
const (
|
||||
Widget FocusState = iota
|
||||
AppBoard
|
||||
NeverFocused
|
||||
widgetFocused FocusState = iota
|
||||
appBoardFocused
|
||||
neverFocused
|
||||
)
|
||||
|
||||
// FocusTracker is used by the app to track which onscreen widget currently has focus,
|
||||
@ -42,7 +42,7 @@ func (tracker *FocusTracker) FocusOn(char string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if tracker.focusState() == AppBoard {
|
||||
if tracker.focusState() == appBoardFocused {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ func (tracker *FocusTracker) FocusOn(char string) bool {
|
||||
// Next sets the focus on the next widget in the widget list. If the current widget is
|
||||
// the last widget, sets focus on the first widget.
|
||||
func (tracker *FocusTracker) Next() {
|
||||
if tracker.focusState() == AppBoard {
|
||||
if tracker.focusState() == appBoardFocused {
|
||||
return
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ func (tracker *FocusTracker) Next() {
|
||||
|
||||
// None removes focus from the currently-focused widget.
|
||||
func (tracker *FocusTracker) None() {
|
||||
if tracker.focusState() == AppBoard {
|
||||
if tracker.focusState() == appBoardFocused {
|
||||
return
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ func (tracker *FocusTracker) None() {
|
||||
// Prev sets the focus on the previous widget in the widget list. If the current widget is
|
||||
// the last widget, sets focus on the last widget.
|
||||
func (tracker *FocusTracker) Prev() {
|
||||
if tracker.focusState() == AppBoard {
|
||||
if tracker.focusState() == appBoardFocused {
|
||||
return
|
||||
}
|
||||
|
||||
@ -156,16 +156,16 @@ func (tracker *FocusTracker) focusableAt(idx int) Wtfable {
|
||||
|
||||
func (tracker *FocusTracker) focusState() FocusState {
|
||||
if tracker.Idx < 0 {
|
||||
return NeverFocused
|
||||
return neverFocused
|
||||
}
|
||||
|
||||
for _, widget := range tracker.Widgets {
|
||||
if widget.TextView() == tracker.App.GetFocus() {
|
||||
return Widget
|
||||
return widgetFocused
|
||||
}
|
||||
}
|
||||
|
||||
return AppBoard
|
||||
return appBoardFocused
|
||||
}
|
||||
|
||||
func (tracker *FocusTracker) increment() {
|
||||
|
@ -57,9 +57,9 @@ func (widget *TextWidget) BorderColor() string {
|
||||
func (widget *TextWidget) ContextualTitle(defaultStr string) string {
|
||||
if widget.FocusChar() == "" {
|
||||
return fmt.Sprintf(" %s ", defaultStr)
|
||||
} else {
|
||||
return fmt.Sprintf(" %s [darkgray::u]%s[::-][green] ", defaultStr, widget.FocusChar())
|
||||
}
|
||||
|
||||
return fmt.Sprintf(" %s [darkgray::u]%s[::-][green] ", defaultStr, widget.FocusChar())
|
||||
}
|
||||
|
||||
func (widget *TextWidget) Disable() {
|
||||
|
@ -119,9 +119,9 @@ func RowColor(module string, idx int) string {
|
||||
|
||||
if idx%2 == 0 {
|
||||
return Config.UString(evenKey, "white")
|
||||
} else {
|
||||
return Config.UString(oddKey, "lightblue")
|
||||
}
|
||||
|
||||
return Config.UString(oddKey, "lightblue")
|
||||
}
|
||||
|
||||
func SigilStr(len, pos int, view *tview.TextView) string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user