1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Some code improvements

* Some assignments simplified by using assignment operators
* Rewrite switch statement with only one case as if.
* Rewrite if-else chain as a switch statement.
* go fmt `modules/todoist/project.go` file.
This commit is contained in:
Kirill Motkov
2019-05-21 17:17:47 +03:00
parent c050292a8d
commit f0771cd013
46 changed files with 161 additions and 168 deletions

View File

@@ -84,7 +84,8 @@ func (widget *Widget) nbascore() string {
quarter := 0.
activate := false
for keyGame, team := range game.(map[string]interface{}) { // assertion
if keyGame == "vTeam" || keyGame == "hTeam" {
switch keyGame {
case "vTeam", "hTeam":
for keyTeam, stat := range team.(map[string]interface{}) {
if keyTeam == "triCode" {
if keyGame == "vTeam" {
@@ -100,13 +101,13 @@ func (widget *Widget) nbascore() string {
}
}
}
} else if keyGame == "period" {
case "period":
for keyTeam, stat := range team.(map[string]interface{}) {
if keyTeam == "current" {
quarter = stat.(float64)
}
}
} else if keyGame == "isGameActivated" {
case "isGameActivated":
activate = team.(bool)
}
}
@@ -114,16 +115,17 @@ func (widget *Widget) nbascore() string {
hNum, _ := strconv.Atoi(hScore)
hColor := ""
if quarter != 0 { // Compare the score
if vNum > hNum {
switch {
case vNum > hNum:
vTeam = "[orange]" + vTeam
} else if hNum > vNum {
case hNum > vNum:
// hScore = "[orange]" + hScore
hColor = "[orange]" // For correct padding
hTeam = hTeam + "[white]"
} else {
hTeam += "[white]"
default:
vTeam = "[orange]" + vTeam
hColor = "[orange]"
hTeam = hTeam + "[white]"
hTeam += "[white]"
}
}
qColor := "[white]"