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

@@ -17,25 +17,24 @@ func (widget *Widget) display() {
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.GitRepos), widget.Idx, width) + "\n"
str = str + " [red]Branch[white]\n"
str = str + fmt.Sprintf(" %s", repoData.Branch)
str = str + "\n"
str = str + widget.formatChanges(repoData.ChangedFiles)
str = str + "\n"
str = str + widget.formatCommits(repoData.Commits)
str += " [red]Branch[white]\n"
str += fmt.Sprintf(" %s", repoData.Branch)
str += "\n"
str += widget.formatChanges(repoData.ChangedFiles)
str += "\n"
str += widget.formatCommits(repoData.Commits)
widget.Redraw(title, str, false)
}
func (widget *Widget) formatChanges(data []string) string {
str := ""
str = str + " [red]Changed Files[white]\n"
str := " [red]Changed Files[white]\n"
if len(data) == 1 {
str = str + " [grey]none[white]\n"
str += " [grey]none[white]\n"
} else {
for _, line := range data {
str = str + widget.formatChange(line)
str += widget.formatChange(line)
}
}
@@ -66,11 +65,10 @@ func (widget *Widget) formatChange(line string) string {
}
func (widget *Widget) formatCommits(data []string) string {
str := ""
str = str + " [red]Recent Commits[white]\n"
str := " [red]Recent Commits[white]\n"
for _, line := range data {
str = str + widget.formatCommit(line)
str += widget.formatCommit(line)
}
return str