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
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, ':')]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue