From 531897b1f0d8176c1f983f921f1d1de618db0131 Mon Sep 17 00:00:00 2001 From: Daniel Schalla Date: Mon, 3 Sep 2018 14:08:40 +0200 Subject: add megacheck as makefile target (#9288) Fix code issues in channel_test.go Fix Channel Test Issues detected by Megacheck Fix API Emoji Test Issues detected by Megacheck Fixed API Issues Reported by Megacheck Fixed App issues reported by megacheck Remaining fixes removed test added by mistake from old HEAD gofmt Store Fixes simplified returns Fix test for multi member channel delete revert to delete unused function --- utils/config.go | 4 +--- utils/i18n.go | 7 +------ utils/jsonutils/json_test.go | 2 -- utils/mail.go | 24 +++++++++++------------- 4 files changed, 13 insertions(+), 24 deletions(-) (limited to 'utils') diff --git a/utils/config.go b/utils/config.go index 3ce2215a3..2e57ec917 100644 --- a/utils/config.go +++ b/utils/config.go @@ -51,9 +51,7 @@ func FindPath(path string, baseSearchPaths []string, filter func(os.FileInfo) bo } searchPaths := []string{} - for _, baseSearchPath := range baseSearchPaths { - searchPaths = append(searchPaths, baseSearchPath) - } + searchPaths = append(searchPaths, baseSearchPaths...) // Additionally attempt to search relative to the location of the running binary. var binaryDir string diff --git a/utils/i18n.go b/utils/i18n.go index d7c55e4e6..4fcd7669d 100644 --- a/utils/i18n.go +++ b/utils/i18n.go @@ -27,12 +27,7 @@ func TranslationsPreInit() error { // segfault trying to handle the error, and the untranslated IDs are strictly better. T = TfuncWithFallback("en") TDefault = TfuncWithFallback("en") - - if err := InitTranslationsWithDir("i18n"); err != nil { - return err - } - - return nil + return InitTranslationsWithDir("i18n") } func InitTranslations(localizationSettings model.LocalizationSettings) error { diff --git a/utils/jsonutils/json_test.go b/utils/jsonutils/json_test.go index b3986e87b..85cb66d60 100644 --- a/utils/jsonutils/json_test.go +++ b/utils/jsonutils/json_test.go @@ -76,8 +76,6 @@ func TestHumanizeJsonError(t *testing.T) { func TestNewHumanizedJsonError(t *testing.T) { t.Parallel() - type testType struct{} - testCases := []struct { Description string Data []byte diff --git a/utils/mail.go b/utils/mail.go index 7b0cb3588..750cb64fe 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -257,20 +257,18 @@ func SendMail(c *smtp.Client, mimeTo, smtpTo string, from mail.Address, subject, m.SetBody("text/plain", txtBody) m.AddAlternative("text/html", htmlMessage) - if attachments != nil { - for _, fileInfo := range attachments { - bytes, err := fileBackend.ReadFile(fileInfo.Path) - if err != nil { - return err - } - - m.Attach(fileInfo.Name, gomail.SetCopyFunc(func(writer io.Writer) error { - if _, err := writer.Write(bytes); err != nil { - return model.NewAppError("SendMail", "utils.mail.sendMail.attachments.write_error", nil, err.Error(), http.StatusInternalServerError) - } - return nil - })) + for _, fileInfo := range attachments { + bytes, err := fileBackend.ReadFile(fileInfo.Path) + if err != nil { + return err } + + m.Attach(fileInfo.Name, gomail.SetCopyFunc(func(writer io.Writer) error { + if _, err := writer.Write(bytes); err != nil { + return model.NewAppError("SendMail", "utils.mail.sendMail.attachments.write_error", nil, err.Error(), http.StatusInternalServerError) + } + return nil + })) } if err := c.Mail(from.Address); err != nil { -- cgit v1.2.3-1-g7c22