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:
parent
c882cf9960
commit
978d35d356
52 changed files with 231 additions and 256 deletions
|
@ -36,8 +36,7 @@ func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
var createParents bool
|
||||
for _, opt := range opts {
|
||||
switch opt.Option {
|
||||
case 'p':
|
||||
if opt.Option == 'p' {
|
||||
createParents = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,16 +61,17 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
} else {
|
||||
modFunc = store.Mark
|
||||
}
|
||||
if all {
|
||||
switch {
|
||||
case all:
|
||||
uids := store.Uids()
|
||||
for _, uid := range uids {
|
||||
modFunc(uid)
|
||||
}
|
||||
return nil
|
||||
} else if visual {
|
||||
case visual:
|
||||
store.ToggleVisualMark()
|
||||
return nil
|
||||
} else {
|
||||
default:
|
||||
modFunc(selected.Uid)
|
||||
return nil
|
||||
}
|
||||
|
@ -80,16 +81,17 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return fmt.Errorf("visual mode not supported for this command")
|
||||
}
|
||||
|
||||
if all && toggle {
|
||||
switch {
|
||||
case all && toggle:
|
||||
uids := store.Uids()
|
||||
for _, uid := range uids {
|
||||
store.ToggleMark(uid)
|
||||
}
|
||||
return nil
|
||||
} else if all && !toggle {
|
||||
case all && !toggle:
|
||||
store.ClearVisualMark()
|
||||
return nil
|
||||
} else {
|
||||
default:
|
||||
store.Unmark(selected.Uid)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -36,8 +36,7 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
var createParents bool
|
||||
for _, opt := range opts {
|
||||
switch opt.Option {
|
||||
case 'p':
|
||||
if opt.Option == 'p' {
|
||||
createParents = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,11 +102,12 @@ func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
flagChosen = true
|
||||
}
|
||||
}
|
||||
if toggle {
|
||||
switch {
|
||||
case toggle:
|
||||
actionName = "Toggling"
|
||||
} else if enable {
|
||||
case enable:
|
||||
actionName = "Setting"
|
||||
} else {
|
||||
default:
|
||||
actionName = "Unsetting"
|
||||
}
|
||||
if optind != len(args) {
|
||||
|
|
|
@ -42,8 +42,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return err
|
||||
}
|
||||
for _, opt := range opts {
|
||||
switch opt.Option {
|
||||
case 'f':
|
||||
if opt.Option == 'f' {
|
||||
force = true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue