lint: homogenize operations and minor fixes (gocritic)

Apply GoDoc comment policy (comments for humans should have a space
after the //; machine-readable comments shouldn't)

Use strings.ReplaceAll instead of strings.Replace when appropriate

Remove if/else chains by replacing them with switches

Use short assignment/increment notation

Replace single case switches with if statements

Combine else and if when appropriate

Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Moritz Poldrack 2022-07-31 14:32:48 +02:00 committed by Robin Jarry
parent c882cf9960
commit 978d35d356
52 changed files with 231 additions and 256 deletions
widgets

View file

@ -527,11 +527,12 @@ func (c *Composer) Close() {
}
func (c *Composer) Bindings() string {
if c.editor == nil {
switch c.editor {
case nil:
return "compose::review"
} else if c.editor == c.focusable[c.focused] {
case c.focusable[c.focused]:
return "compose::editor"
} else {
default:
return "compose"
}
}
@ -798,10 +799,8 @@ func (c *Composer) resetReview() {
}
func (c *Composer) termEvent(event tcell.Event) bool {
switch event := event.(type) {
case *tcell.EventMouse:
switch event.Buttons() {
case tcell.Button1:
if event, ok := event.(*tcell.EventMouse); ok {
if event.Buttons() == tcell.Button1 {
c.FocusTerminal()
return true
}
@ -1041,10 +1040,8 @@ func (he *headerEditor) Draw(ctx *ui.Context) {
}
func (he *headerEditor) MouseEvent(localX int, localY int, event tcell.Event) {
switch event := event.(type) {
case *tcell.EventMouse:
switch event.Buttons() {
case tcell.Button1:
if event, ok := event.(*tcell.EventMouse); ok {
if event.Buttons() == tcell.Button1 {
he.focused = true
}
@ -1120,7 +1117,7 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage {
inputs = append(inputs, config.FormatKeyStrokes(input))
}
actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
strings.Join(inputs[:], ", "), name, cmd))
strings.Join(inputs, ", "), name, cmd))
}
spec := []ui.GridSpec{