1
0
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:
Chris Cummer 2018-08-03 05:40:39 -07:00
parent 1f27cf5b00
commit 72c192cabf
12 changed files with 38 additions and 37 deletions

View File

@ -15,9 +15,9 @@ type ChecklistItem struct {
func (item *ChecklistItem) CheckMark() string { func (item *ChecklistItem) CheckMark() string {
if item.Checked { if item.Checked {
return wtf.Config.UString("wtf.mods.todo.checkedIcon", "x") return wtf.Config.UString("wtf.mods.todo.checkedIcon", "x")
} else {
return " "
} }
return " "
} }
// Toggle changes the checked state of the ChecklistItem // Toggle changes the checked state of the ChecklistItem

View File

@ -45,9 +45,9 @@ func (widget *Widget) String() string {
if args != "" { if args != "" {
return fmt.Sprintf(" %s %s ", widget.cmd, 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() { func (widget *Widget) execute() {

View File

@ -50,9 +50,9 @@ func (calEvent *CalEvent) Past() bool {
if calEvent.AllDay() { if calEvent.AllDay() {
// FIXME: This should calculate properly // FIXME: This should calculate properly
return false 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 { func (calEvent *CalEvent) ResponseFor(email string) string {
@ -97,8 +97,8 @@ func (calEvent *CalEvent) Timestamp() string {
if calEvent.AllDay() { if calEvent.AllDay() {
startTime, _ := time.Parse("2006-01-02", calEvent.event.Start.Date) startTime, _ := time.Parse("2006-01-02", calEvent.event.Start.Date)
return startTime.Format(wtf.FriendlyDateFormat) return startTime.Format(wtf.FriendlyDateFormat)
} else { }
startTime, _ := time.Parse(time.RFC3339, calEvent.event.Start.DateTime) startTime, _ := time.Parse(time.RFC3339, calEvent.event.Start.DateTime)
return startTime.Format(wtf.MinimumTimeFormat) return startTime.Format(wtf.MinimumTimeFormat)
} }
}

View File

@ -73,9 +73,9 @@ func Fetch() ([]*CalEvent, error) {
timeDateChooser := func(event *calendar.Event) (time.Time, error) { timeDateChooser := func(event *calendar.Event) (time.Time, error) {
if len(event.Start.Date) > 0 { if len(event.Start.Date) > 0 {
return time.Parse("2006-01-02", event.Start.Date) 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 { sort.Slice(events.Items, func(i, j int) bool {

View File

@ -109,9 +109,9 @@ func (widget *Widget) dayDivider(event, prevEvent *CalEvent) string {
func (widget *Widget) descriptionColor(calEvent *CalEvent) string { func (widget *Widget) descriptionColor(calEvent *CalEvent) string {
if calEvent.Past() { if calEvent.Past() {
return wtf.Config.UString("wtf.mods.gcal.colors.past", "gray") 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 { func (widget *Widget) eventSummary(calEvent *CalEvent, conflict bool) string {
@ -127,9 +127,9 @@ func (widget *Widget) eventSummary(calEvent *CalEvent, conflict bool) string {
if conflict { if conflict {
return fmt.Sprintf("%s %s", wtf.Config.UString("wtf.mods.gcal.conflictIcon", "🚨"), summary) 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 // timeUntil returns the number of hours or days until the event

View File

@ -52,7 +52,7 @@ func dnsMacOS() []string {
if len(lines) > 0 { if len(lines) > 0 {
return lines return lines
} else { }
return []string{} return []string{}
} }
}

View File

@ -83,9 +83,9 @@ func wifiNameMacOS() string {
func matchStr(data [][]string) string { func matchStr(data [][]string) string {
if len(data) <= 1 { if len(data) <= 1 {
return "" return ""
} else {
return data[1][1]
} }
return data[1][1]
} }
//Windows //Windows

View File

@ -48,9 +48,10 @@ func (widget *Widget) Refresh() {
func (widget *Widget) prettyDate() string { func (widget *Widget) prettyDate() string {
str, err := time.Parse(wtf.TimestampFormat, widget.Date) str, err := time.Parse(wtf.TimestampFormat, widget.Date)
if err != nil { if err != nil {
return err.Error() return err.Error()
} else { }
return str.Format("Jan _2, 15:04") return str.Format("Jan _2, 15:04")
} }
}

View File

@ -425,9 +425,9 @@ func ASCIItoTviewColors(text string) string {
func colorFor(label string) tcell.Color { func colorFor(label string) tcell.Color {
if _, ok := colors[label]; ok { if _, ok := colors[label]; ok {
return colors[label] return colors[label]
} else {
return tcell.ColorGreen
} }
return tcell.ColorGreen
} }
func replaceWithHexColorString(substring string) string { func replaceWithHexColorString(substring string) string {

View File

@ -7,9 +7,9 @@ import (
type FocusState int type FocusState int
const ( const (
Widget FocusState = iota widgetFocused FocusState = iota
AppBoard appBoardFocused
NeverFocused neverFocused
) )
// FocusTracker is used by the app to track which onscreen widget currently has focus, // 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 return false
} }
if tracker.focusState() == AppBoard { if tracker.focusState() == appBoardFocused {
return false 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 // 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. // the last widget, sets focus on the first widget.
func (tracker *FocusTracker) Next() { func (tracker *FocusTracker) Next() {
if tracker.focusState() == AppBoard { if tracker.focusState() == appBoardFocused {
return return
} }
@ -76,7 +76,7 @@ func (tracker *FocusTracker) Next() {
// None removes focus from the currently-focused widget. // None removes focus from the currently-focused widget.
func (tracker *FocusTracker) None() { func (tracker *FocusTracker) None() {
if tracker.focusState() == AppBoard { if tracker.focusState() == appBoardFocused {
return 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 // 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. // the last widget, sets focus on the last widget.
func (tracker *FocusTracker) Prev() { func (tracker *FocusTracker) Prev() {
if tracker.focusState() == AppBoard { if tracker.focusState() == appBoardFocused {
return return
} }
@ -156,16 +156,16 @@ func (tracker *FocusTracker) focusableAt(idx int) Wtfable {
func (tracker *FocusTracker) focusState() FocusState { func (tracker *FocusTracker) focusState() FocusState {
if tracker.Idx < 0 { if tracker.Idx < 0 {
return NeverFocused return neverFocused
} }
for _, widget := range tracker.Widgets { for _, widget := range tracker.Widgets {
if widget.TextView() == tracker.App.GetFocus() { if widget.TextView() == tracker.App.GetFocus() {
return Widget return widgetFocused
} }
} }
return AppBoard return appBoardFocused
} }
func (tracker *FocusTracker) increment() { func (tracker *FocusTracker) increment() {

View File

@ -57,9 +57,9 @@ func (widget *TextWidget) BorderColor() string {
func (widget *TextWidget) ContextualTitle(defaultStr string) string { func (widget *TextWidget) ContextualTitle(defaultStr string) string {
if widget.FocusChar() == "" { if widget.FocusChar() == "" {
return fmt.Sprintf(" %s ", defaultStr) 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() { func (widget *TextWidget) Disable() {

View File

@ -119,9 +119,9 @@ func RowColor(module string, idx int) string {
if idx%2 == 0 { if idx%2 == 0 {
return Config.UString(evenKey, "white") 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 { func SigilStr(len, pos int, view *tview.TextView) string {