From 15303e32cfc96dfd918f0f765dadb6291f5f36e4 Mon Sep 17 00:00:00 2001 From: Shubhendra Singh Chauhan Date: Thu, 25 Feb 2021 05:04:38 +0530 Subject: [PATCH] Fix code quality issues (#2118) --- controllers/route.go | 4 ++-- imap/monitor.go | 2 +- middleware/ratelimit/ratelimit.go | 2 +- models/email_request.go | 2 +- models/maillog.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controllers/route.go b/controllers/route.go index 58b1b974..2fdcf2e9 100644 --- a/controllers/route.go +++ b/controllers/route.go @@ -301,7 +301,7 @@ func (as *AdminServer) nextOrIndex(w http.ResponseWriter, r *http.Request) { next = path } } - http.Redirect(w, r, next, 302) + http.Redirect(w, r, next, http.StatusFound) } func (as *AdminServer) handleInvalidLogin(w http.ResponseWriter, r *http.Request, message string) { @@ -386,7 +386,7 @@ func (as *AdminServer) Login(w http.ResponseWriter, r *http.Request) { as.handleInvalidLogin(w, r, "Invalid Username/Password") return } - if u.AccountLocked == true { + if u.AccountLocked { as.handleInvalidLogin(w, r, "Account Locked") return } diff --git a/imap/monitor.go b/imap/monitor.go index 779c2b16..da47fc98 100644 --- a/imap/monitor.go +++ b/imap/monitor.go @@ -174,7 +174,7 @@ func checkForNewEmails(im models.IMAP) { log.Error("Error updating GoPhish email with rid ", rid, ": ", err.Error()) continue } - if im.DeleteReportedCampaignEmail == true { + if im.DeleteReportedCampaignEmail { deleteEmails = append(deleteEmails, m.SeqNum) } } diff --git a/middleware/ratelimit/ratelimit.go b/middleware/ratelimit/ratelimit.go index e382dd7a..5549008d 100644 --- a/middleware/ratelimit/ratelimit.go +++ b/middleware/ratelimit/ratelimit.go @@ -91,7 +91,7 @@ func (limiter *PostLimiter) Cleanup() { limiter.Lock() defer limiter.Unlock() for ip, bucket := range limiter.visitors { - if time.Now().Sub(bucket.lastSeen) >= limiter.expiry { + if time.Since(bucket.lastSeen) >= limiter.expiry { delete(limiter.visitors, ip) } } diff --git a/models/email_request.go b/models/email_request.go index 706fe1dd..35d2e6b9 100644 --- a/models/email_request.go +++ b/models/email_request.go @@ -144,7 +144,7 @@ func (s *EmailRequest) Generate(msg *gomail.Message) error { log.Error(err) } // don't set the Subject header if it is blank - if len(subject) != 0 { + if subject != "" { msg.SetHeader("Subject", subject) } diff --git a/models/maillog.go b/models/maillog.go index ea56ca13..07518028 100644 --- a/models/maillog.go +++ b/models/maillog.go @@ -215,7 +215,7 @@ func (m *MailLog) Generate(msg *gomail.Message) error { log.Warn(err) } // don't set Subject header if the subject is empty - if len(subject) != 0 { + if subject != "" { msg.SetHeader("Subject", subject) }