all: fix minor issues found by staticcheck

Signed-off-by: Moritz Poldrack <git@moritz.sh>
This commit is contained in:
Moritz Poldrack 2022-03-09 22:48:00 +01:00 committed by Robin Jarry
parent 65ae87a524
commit 4bc43d2741
11 changed files with 17 additions and 27 deletions

View File

@ -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
}

View File

@ -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 {

View File

@ -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
}
}

View File

@ -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]
}
}

View File

@ -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 ~

View File

@ -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)
}
}

View File

@ -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"))
}
}
}

View File

@ -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)

View File

@ -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)
}

View File

@ -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())

View File

@ -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