lint: simplify code (gosimple)
Replaces infinite for loops containing a select on a channel with a single case with a range over the channel. Removes redundant assignments to blank identifiers. Remove unnecessary guard clause around delete(). Remove `if condition { return true } return false` with return condition Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
03f9f4c3ab
commit
ef599aa8fc
6 changed files with 28 additions and 39 deletions
|
@ -19,8 +19,5 @@ func NoQuitDone() {
|
||||||
// QuitAllowed checks if aerc can exit normally (only when all goroutines that
|
// QuitAllowed checks if aerc can exit normally (only when all goroutines that
|
||||||
// requested a no-quit mode were done and called the NoQuitDone() function)
|
// requested a no-quit mode were done and called the NoQuitDone() function)
|
||||||
func QuitAllowed() bool {
|
func QuitAllowed() bool {
|
||||||
if atomic.LoadInt32(&noquit) > 0 {
|
return atomic.LoadInt32(&noquit) <= 0
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,11 +452,9 @@ func (store *MessageStore) Delete(uids []uint32,
|
||||||
|
|
||||||
func (store *MessageStore) revertDeleted(uids []uint32) {
|
func (store *MessageStore) revertDeleted(uids []uint32) {
|
||||||
for _, uid := range uids {
|
for _, uid := range uids {
|
||||||
if _, ok := store.Deleted[uid]; ok {
|
|
||||||
delete(store.Deleted, uid)
|
delete(store.Deleted, uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool,
|
func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool,
|
||||||
cb func(msg types.WorkerMessage),
|
cb func(msg types.WorkerMessage),
|
||||||
|
|
|
@ -194,7 +194,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
|
||||||
}
|
}
|
||||||
wizard.imapUri()
|
wizard.imapUri()
|
||||||
}
|
}
|
||||||
hostport, srv = getSRV(server, []string{"submission"})
|
hostport, _ = getSRV(server, []string{"submission"})
|
||||||
if hostport != "" {
|
if hostport != "" {
|
||||||
wizard.smtpServer.Set(hostport)
|
wizard.smtpServer.Set(hostport)
|
||||||
wizard.smtpMode = SMTP_STARTTLS
|
wizard.smtpMode = SMTP_STARTTLS
|
||||||
|
|
|
@ -385,7 +385,7 @@ func buildTree(node *types.Thread, stree [][]string, defaultUid uint32) {
|
||||||
}
|
}
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
next, _ := m[key]
|
next := m[key]
|
||||||
var uid uint32 = defaultUid
|
var uid uint32 = defaultUid
|
||||||
for _, testStr := range next {
|
for _, testStr := range next {
|
||||||
if len(testStr) == 1 {
|
if len(testStr) == 1 {
|
||||||
|
|
|
@ -134,8 +134,7 @@ func (i *idler) waitOnIdle() {
|
||||||
i.log("wait for idle in background")
|
i.log("wait for idle in background")
|
||||||
go func() {
|
go func() {
|
||||||
defer logging.PanicHandler()
|
defer logging.PanicHandler()
|
||||||
select {
|
err := <-i.done
|
||||||
case err := <-i.done:
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
i.log("<=(idle) waited")
|
i.log("<=(idle) waited")
|
||||||
i.log("connect done->")
|
i.log("connect done->")
|
||||||
|
@ -149,8 +148,6 @@ func (i *idler) waitOnIdle() {
|
||||||
i.stop = make(chan struct{})
|
i.stop = make(chan struct{})
|
||||||
i.log("restart")
|
i.log("restart")
|
||||||
i.Start()
|
i.Start()
|
||||||
return
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -363,9 +363,7 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *mboxWorker) Run() {
|
func (w *mboxWorker) Run() {
|
||||||
for {
|
for msg := range w.worker.Actions {
|
||||||
select {
|
|
||||||
case msg := <-w.worker.Actions:
|
|
||||||
msg = w.worker.ProcessAction(msg)
|
msg = w.worker.ProcessAction(msg)
|
||||||
if err := w.handleMessage(msg); err == errUnsupported {
|
if err := w.handleMessage(msg); err == errUnsupported {
|
||||||
w.worker.PostMessage(&types.Unsupported{
|
w.worker.PostMessage(&types.Unsupported{
|
||||||
|
@ -379,4 +377,3 @@ func (w *mboxWorker) Run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue