diff options
author | Moritz Poldrack <git@moritz.sh> | 2022-07-31 14:32:48 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-08-04 21:58:01 +0200 |
commit | 978d35d356e8752bdd272884df48a6289d88b40a (patch) | |
tree | 3910243e688ef503159d07ce44b22cfea5d6c6fd /commands/compose | |
parent | c882cf9960be691fe55617b87cdfcfbabd5d5557 (diff) | |
download | aerc-978d35d356e8752bdd272884df48a6289d88b40a.tar.gz |
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>
Diffstat (limited to 'commands/compose')
-rw-r--r-- | commands/compose/header.go | 3 | ||||
-rw-r--r-- | commands/compose/send.go | 25 |
2 files changed, 13 insertions, 15 deletions
diff --git a/commands/compose/header.go b/commands/compose/header.go index dcee9aac..46cc23b9 100644 --- a/commands/compose/header.go +++ b/commands/compose/header.go @@ -50,8 +50,7 @@ func (Header) Execute(aerc *widgets.Aerc, args []string) error { var force bool = false for _, opt := range opts { - switch opt.Option { - case 'f': + if opt.Option == 'f' { force = true } } diff --git a/commands/compose/send.go b/commands/compose/send.go index 2bd61119..ec9e06b3 100644 --- a/commands/compose/send.go +++ b/commands/compose/send.go @@ -250,12 +250,13 @@ func parseScheme(uri *url.URL) (scheme string, auth string, err error) { auth = "plain" if uri.Scheme != "" { parts := strings.Split(uri.Scheme, "+") - if len(parts) == 1 { + switch len(parts) { + case 1: scheme = parts[0] - } else if len(parts) == 2 { + case 2: scheme = parts[0] auth = parts[1] - } else { + default: return "", "", fmt.Errorf("Unknown transfer protocol %s", uri.Scheme) } } @@ -380,7 +381,7 @@ func newSmtpSender(ctx sendCtx) (io.WriteCloser, error) { func connectSmtp(starttls bool, host string) (*smtp.Client, error) { serverName := host if !strings.ContainsRune(host, ':') { - host = host + ":587" // Default to submission port + host += ":587" // Default to submission port } else { serverName = host[:strings.IndexRune(host, ':')] } @@ -402,14 +403,12 @@ func connectSmtp(starttls bool, host string) (*smtp.Client, error) { conn.Close() return nil, errors.Wrap(err, "StartTLS") } - } else { - if starttls { - err := errors.New("STARTTLS requested, but not supported " + - "by this SMTP server. Is someone tampering with your " + - "connection?") - conn.Close() - return nil, err - } + } else if starttls { + err := errors.New("STARTTLS requested, but not supported " + + "by this SMTP server. Is someone tampering with your " + + "connection?") + conn.Close() + return nil, err } return conn, nil } @@ -417,7 +416,7 @@ func connectSmtp(starttls bool, host string) (*smtp.Client, error) { func connectSmtps(host string) (*smtp.Client, error) { serverName := host if !strings.ContainsRune(host, ':') { - host = host + ":465" // Default to smtps port + host += ":465" // Default to smtps port } else { serverName = host[:strings.IndexRune(host, ':')] } |