aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Poldrack <git@moritz.sh>2022-03-09 22:48:00 +0100
committerRobin Jarry <robin@jarry.cc>2022-03-12 21:00:23 +0100
commit4bc43d2741fa4904e51fc5da71d15b804c556c43 (patch)
tree1747e08585ef0c98a13d3477369b4f159071a762
parent65ae87a524ebbb573626afe951d6cd29bc8b24cd (diff)
downloadaerc-4bc43d2741fa4904e51fc5da71d15b804c556c43.tar.gz
all: fix minor issues found by staticcheck
Signed-off-by: Moritz Poldrack <git@moritz.sh>
-rw-r--r--commands/compose/send.go2
-rw-r--r--commands/msg/delete.go15
-rw-r--r--commands/msg/reply.go2
-rw-r--r--commands/msgview/open.go2
-rw-r--r--commands/msgview/save.go6
-rw-r--r--lib/msgstore.go2
-rw-r--r--lib/socket.go2
-rw-r--r--widgets/aerc.go3
-rw-r--r--widgets/compose.go1
-rw-r--r--widgets/msgviewer.go5
-rw-r--r--widgets/terminal.go4
11 files changed, 17 insertions, 27 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 12bf155c..dbdb94f9 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -189,7 +189,7 @@ func newSendmailSender(ctx sendCtx) (io.WriteCloser, error) {
return nil, fmt.Errorf("no command specified")
}
bin := args[0]
- rs := make([]string, len(ctx.rcpts), len(ctx.rcpts))
+ rs := make([]string, len(ctx.rcpts))
for i := range ctx.rcpts {
rs[i] = ctx.rcpts[i].Address
}
diff --git a/commands/msg/delete.go b/commands/msg/delete.go
index 34eac72f..5eb622de 100644
--- a/commands/msg/delete.go
+++ b/commands/msg/delete.go
@@ -88,15 +88,14 @@ func findNextNonDeleted(deleted []uint32, store *lib.MessageStore) *models.Messa
if !contains(deleted, selected.Uid) {
return selected
}
- for {
- store.Next()
- next := store.Selected()
- if next == selected || next == nil {
- // the last message is in the deleted state or doesn't exist
- return nil
- }
- return next
+
+ store.Next()
+ next := store.Selected()
+ if next == selected || next == nil {
+ // the last message is in the deleted state or doesn't exist
+ return nil
}
+ return next
}
func contains(uids []uint32, uid uint32) bool {
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index c3ab202c..30b09b62 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -122,7 +122,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
}
}
if len(to) == 0 {
- to = append(msg.Envelope.To)
+ to = msg.Envelope.To
}
}
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index bcfe2b48..5b199120 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -37,7 +37,7 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
if part, err := p.Msg.BodyStructure.PartAtIndex(p.Index); err == nil {
mimeType := fmt.Sprintf("%s/%s", part.MIMEType, part.MIMESubType)
- if exts, _ := mime.ExtensionsByType(mimeType); exts != nil && len(exts) > 0 {
+ if exts, _ := mime.ExtensionsByType(mimeType); len(exts) > 0 {
extension = exts[0]
}
}
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 713c6d11..26a6bf2e 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -151,10 +151,8 @@ func isDirExists(path string) bool {
//pathExists returns true if path exists
func pathExists(path string) bool {
_, err := os.Stat(path)
- if err != nil {
- return false // we don't really care why it failed
- }
- return true
+
+ return err == nil
}
//isAbsPath returns true if path given is anchored to / or . or ~
diff --git a/lib/msgstore.go b/lib/msgstore.go
index bd9e935b..5a86d41e 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -575,7 +575,7 @@ func (store *MessageStore) updateVisual() {
}
missing := make([]uint32, 0)
for _, uid := range visUids {
- if msg, _ := store.Messages[uid]; msg == nil {
+ if msg := store.Messages[uid]; msg == nil {
missing = append(missing, uid)
}
}
diff --git a/lib/socket.go b/lib/socket.go
index 119ffdad..814dce12 100644
--- a/lib/socket.go
+++ b/lib/socket.go
@@ -83,7 +83,7 @@ func (as *AercServer) handleClient(conn net.Conn) {
if err != nil {
conn.Write([]byte(fmt.Sprintf("result: %v\n", err)))
} else {
- conn.Write([]byte(fmt.Sprint("result: success\n")))
+ conn.Write([]byte("result: success\n"))
}
}
}
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 98bc1b23..8061f388 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -598,13 +598,11 @@ func (aerc *Aerc) AddDialog(d ui.DrawableInteractive) {
aerc.Invalidate()
})
aerc.Invalidate()
- return
}
func (aerc *Aerc) CloseDialog() {
aerc.dialog = nil
aerc.Invalidate()
- return
}
func (aerc *Aerc) GetPassword(title string, prompt string) (chText chan string, chErr chan error) {
@@ -622,7 +620,6 @@ func (aerc *Aerc) GetPassword(title string, prompt string) (chText chan string,
}
chErr <- nil
chText <- pw
- return
})
aerc.AddDialog(getPasswd)
diff --git a/widgets/compose.go b/widgets/compose.go
index e47aa3eb..977c4c43 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -876,7 +876,6 @@ func (he *headerEditor) storeValue() {
// fix the issue
he.header.SetText(he.name, val)
}
- val = format.FormatAddresses(list)
default:
he.header.SetText(he.name, val)
}
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index dba2bc6d..da81ec95 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -54,10 +54,7 @@ func NewMessageViewer(acct *AccountView,
hf := HeaderLayoutFilter{
layout: HeaderLayout(conf.Viewer.HeaderLayout),
keep: func(msg *models.MessageInfo, header string) bool {
- if fmtHeader(msg, header, "2") != "" {
- return true
- }
- return false
+ return fmtHeader(msg, header, "2") != ""
},
}
layout := hf.forMessage(msg.MessageInfo())
diff --git a/widgets/terminal.go b/widgets/terminal.go
index b6e8fc0e..a9c79884 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -134,7 +134,7 @@ func NewTerminal(cmd *exec.Cmd) (*Terminal, error) {
return
}
term.writeMutex.Lock()
- n, err = term.vterm.Write(buf[:n])
+ _, err = term.vterm.Write(buf[:n])
term.writeMutex.Unlock()
if err != nil {
term.Close(err)
@@ -166,7 +166,7 @@ func (term *Terminal) flushTerminal() {
if n == 0 {
break
}
- n, err = term.pty.Write(buf[:n])
+ _, err = term.pty.Write(buf[:n])
if err != nil {
term.Close(err)
return