Fix code quality issues (#2118)

pull/2140/head
Shubhendra Singh Chauhan 2021-02-25 05:04:38 +05:30 committed by GitHub
parent e6533e9993
commit 15303e32cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -301,7 +301,7 @@ func (as *AdminServer) nextOrIndex(w http.ResponseWriter, r *http.Request) {
next = path 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) { 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") as.handleInvalidLogin(w, r, "Invalid Username/Password")
return return
} }
if u.AccountLocked == true { if u.AccountLocked {
as.handleInvalidLogin(w, r, "Account Locked") as.handleInvalidLogin(w, r, "Account Locked")
return return
} }

View File

@ -174,7 +174,7 @@ func checkForNewEmails(im models.IMAP) {
log.Error("Error updating GoPhish email with rid ", rid, ": ", err.Error()) log.Error("Error updating GoPhish email with rid ", rid, ": ", err.Error())
continue continue
} }
if im.DeleteReportedCampaignEmail == true { if im.DeleteReportedCampaignEmail {
deleteEmails = append(deleteEmails, m.SeqNum) deleteEmails = append(deleteEmails, m.SeqNum)
} }
} }

View File

@ -91,7 +91,7 @@ func (limiter *PostLimiter) Cleanup() {
limiter.Lock() limiter.Lock()
defer limiter.Unlock() defer limiter.Unlock()
for ip, bucket := range limiter.visitors { 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) delete(limiter.visitors, ip)
} }
} }

View File

@ -144,7 +144,7 @@ func (s *EmailRequest) Generate(msg *gomail.Message) error {
log.Error(err) log.Error(err)
} }
// don't set the Subject header if it is blank // don't set the Subject header if it is blank
if len(subject) != 0 { if subject != "" {
msg.SetHeader("Subject", subject) msg.SetHeader("Subject", subject)
} }

View File

@ -215,7 +215,7 @@ func (m *MailLog) Generate(msg *gomail.Message) error {
log.Warn(err) log.Warn(err)
} }
// don't set Subject header if the subject is empty // don't set Subject header if the subject is empty
if len(subject) != 0 { if subject != "" {
msg.SetHeader("Subject", subject) msg.SetHeader("Subject", subject)
} }