diff --git a/app/command_autocomplete.go b/app/command_autocomplete.go index dbf8c03952..676efd2eee 100644 --- a/app/command_autocomplete.go +++ b/app/command_autocomplete.go @@ -307,18 +307,18 @@ func (a *App) getBuiltinDynamicListArgument(commandArgs *model.CommandArgs, arg dynamicArg := arg.Data.(*model.AutocompleteDynamicListArg) arr := strings.Split(dynamicArg.FetchURL, ":") if len(arr) < 2 { - return nil, errors.New("Dynamic list URL missing built-in command name") + return nil, errors.New("dynamic list URL missing built-in command name") } cmdName := arr[1] provider := GetCommandProvider(cmdName) if provider == nil { - return nil, fmt.Errorf("No command provider for %s", cmdName) + return nil, fmt.Errorf("no command provider for %s", cmdName) } dp, ok := provider.(AutocompleteDynamicArgProvider) if !ok { - return nil, fmt.Errorf("Auto-completion not available for built-in command %s", cmdName) + return nil, fmt.Errorf("auto-completion not available for built-in command %s", cmdName) } return dp.GetAutoCompleteListItems(a, commandArgs, arg, parsed, toBeParsed) diff --git a/app/file_test.go b/app/file_test.go index d04732b14b..49ee9b36cb 100644 --- a/app/file_test.go +++ b/app/file_test.go @@ -278,11 +278,12 @@ func TestCreateZipFileAndAddFiles(t *testing.T) { defer th.TearDown() mockBackend := mocks.FileBackend{} - mockBackend.On("WriteFile", mock.Anything, "directory-to-heaven/zip-file-name-to-heaven.zip").Return(int64(666), errors.New("Only those who dare to fail greatly can ever achieve greatly")) + mockBackend.On("WriteFile", mock.Anything, "directory-to-heaven/zip-file-name-to-heaven.zip").Return(int64(666), errors.New("only those who dare to fail greatly can ever achieve greatly")) err := th.App.CreateZipFileAndAddFiles(&mockBackend, []model.FileData{}, "zip-file-name-to-heaven.zip", "directory-to-heaven") - require.Error(t, err) - require.Equal(t, err.Error(), "Only those who dare to fail greatly can ever achieve greatly") + + require.NotNil(t, err) + require.Equal(t, err.Error(), "only those who dare to fail greatly can ever achieve greatly") mockBackend = mocks.FileBackend{} mockBackend.On("WriteFile", mock.Anything, "directory-to-heaven/zip-file-name-to-heaven.zip").Return(int64(666), nil) diff --git a/app/layer_generators/main.go b/app/layer_generators/main.go index 17e8ffc9b1..5ac8b8ac48 100644 --- a/app/layer_generators/main.go +++ b/app/layer_generators/main.go @@ -160,7 +160,7 @@ func extractStoreMetadata() (*storeMetadata, error) { file, err := os.Open(inputFile) if err != nil { - return nil, fmt.Errorf("Unable to open %s file: %w", inputFile, err) + return nil, fmt.Errorf("unable to open %s file: %w", inputFile, err) } src, err := ioutil.ReadAll(file) if err != nil { diff --git a/plugin/client_rpc.go b/plugin/client_rpc.go index afa8412dad..87871eb075 100644 --- a/plugin/client_rpc.go +++ b/plugin/client_rpc.go @@ -436,7 +436,7 @@ func (s *apiRPCServer) PluginHTTP(args *Z_PluginHTTPArgs, returns *Z_PluginHTTPR returns.Response = response returns.ResponseBody = responseBody } else { - return encodableError(fmt.Errorf("API PluginHTTP called but not implemented.")) + return encodableError(fmt.Errorf("API PluginHTTP called but not implemented")) } return nil } @@ -524,7 +524,7 @@ func (s *hooksRPCServer) FileWillBeUploaded(args *Z_FileWillBeUploadedArgs, retu }); ok { returns.A, returns.B = hook.FileWillBeUploaded(args.A, args.B, fileReader, returnFileWriter) } else { - return fmt.Errorf("Hook FileWillBeUploaded called but not implemented.") + return fmt.Errorf("hook FileWillBeUploaded called but not implemented") } return nil } @@ -564,7 +564,7 @@ func (s *hooksRPCServer) MessageWillBePosted(args *Z_MessageWillBePostedArgs, re returns.A, returns.B = hook.MessageWillBePosted(args.A, args.B) } else { - return encodableError(fmt.Errorf("Hook MessageWillBePosted called but not implemented.")) + return encodableError(fmt.Errorf("hook MessageWillBePosted called but not implemented")) } return nil } @@ -605,7 +605,7 @@ func (s *hooksRPCServer) MessageWillBeUpdated(args *Z_MessageWillBeUpdatedArgs, returns.A, returns.B = hook.MessageWillBeUpdated(args.A, args.B, args.C) } else { - return encodableError(fmt.Errorf("Hook MessageWillBeUpdated called but not implemented.")) + return encodableError(fmt.Errorf("hook MessageWillBeUpdated called but not implemented")) } return nil } @@ -634,7 +634,7 @@ func (s *apiRPCServer) LogDebug(args *Z_LogDebugArgs, returns *Z_LogDebugReturns }); ok { hook.LogDebug(args.A, args.B...) } else { - return encodableError(fmt.Errorf("API LogDebug called but not implemented.")) + return encodableError(fmt.Errorf("API LogDebug called but not implemented")) } return nil } @@ -663,7 +663,7 @@ func (s *apiRPCServer) LogInfo(args *Z_LogInfoArgs, returns *Z_LogInfoReturns) e }); ok { hook.LogInfo(args.A, args.B...) } else { - return encodableError(fmt.Errorf("API LogInfo called but not implemented.")) + return encodableError(fmt.Errorf("API LogInfo called but not implemented")) } return nil } @@ -692,7 +692,7 @@ func (s *apiRPCServer) LogWarn(args *Z_LogWarnArgs, returns *Z_LogWarnReturns) e }); ok { hook.LogWarn(args.A, args.B...) } else { - return encodableError(fmt.Errorf("API LogWarn called but not implemented.")) + return encodableError(fmt.Errorf("API LogWarn called but not implemented")) } return nil } @@ -720,7 +720,7 @@ func (s *apiRPCServer) LogError(args *Z_LogErrorArgs, returns *Z_LogErrorReturns }); ok { hook.LogError(args.A, args.B...) } else { - return encodableError(fmt.Errorf("API LogError called but not implemented.")) + return encodableError(fmt.Errorf("API LogError called but not implemented")) } return nil } @@ -762,7 +762,7 @@ func (s *apiRPCServer) InstallPlugin(args *Z_InstallPluginArgs, returns *Z_Insta InstallPlugin(file io.Reader, replace bool) (*model.Manifest, *model.AppError) }) if !ok { - return encodableError(fmt.Errorf("API InstallPlugin called but not implemented.")) + return encodableError(fmt.Errorf("API InstallPlugin called but not implemented")) } receivePluginConnection, err := s.muxBroker.Dial(args.PluginStreamID) diff --git a/plugin/supervisor.go b/plugin/supervisor.go index 1ddac1db62..3264e2b8d6 100644 --- a/plugin/supervisor.go +++ b/plugin/supervisor.go @@ -122,8 +122,7 @@ func (sup *supervisor) PerformHealthCheck() error { } } if pingErr != nil { - mlog.Debug("Error pinging plugin", mlog.Err(pingErr)) - return fmt.Errorf("Plugin RPC connection is not responding") + return fmt.Errorf("plugin RPC connection is not responding") } } diff --git a/services/docextractor/documents.go b/services/docextractor/documents.go index 05531aa884..38a47881d7 100644 --- a/services/docextractor/documents.go +++ b/services/docextractor/documents.go @@ -37,7 +37,7 @@ func (de *documentExtractor) Extract(filename string, r io.Reader) (string, erro extension := strings.TrimPrefix(path.Ext(filename), ".") converter, ok := doconvConverterByExtensions[extension] if !ok { - return "", errors.New("Unknown converter") + return "", errors.New("unknown converter") } f, err := ioutil.TempFile(os.TempDir(), "docconv") diff --git a/services/mailservice/inbucket.go b/services/mailservice/inbucket.go index 08d0ce28f1..2ff58e1fe4 100644 --- a/services/mailservice/inbucket.go +++ b/services/mailservice/inbucket.go @@ -70,19 +70,19 @@ func GetMailBox(email string) (results JSONMessageHeaderInbucket, err error) { }() if resp.Body == nil { - return nil, fmt.Errorf("No Mailbox") + return nil, fmt.Errorf("no mailbox") } var record JSONMessageHeaderInbucket err = json.NewDecoder(resp.Body).Decode(&record) switch { case err == io.EOF: - return nil, fmt.Errorf("Error: %s", err) + return nil, fmt.Errorf("error: %s", err) case err != nil: - return nil, fmt.Errorf("Error: %s", err) + return nil, fmt.Errorf("error: %s", err) } if len(record) == 0 { - return nil, fmt.Errorf("No mailbox") + return nil, fmt.Errorf("no mailbox") } return record, nil @@ -171,7 +171,7 @@ func RetryInbucket(attempts int, callback func() error) (err error) { fmt.Println("retrying...") } - return fmt.Errorf("After %d attempts, last error: %s", attempts, err) + return fmt.Errorf("after %d attempts, last error: %s", attempts, err) } func getInbucketHost() (host string) { diff --git a/store/layer_generators/main.go b/store/layer_generators/main.go index bb78ed9241..940bdfe3e9 100644 --- a/store/layer_generators/main.go +++ b/store/layer_generators/main.go @@ -153,7 +153,7 @@ func extractStoreMetadata() (*storeMetadata, error) { file, err := os.Open("store.go") if err != nil { - return nil, fmt.Errorf("Unable to open store/store.go file: %w", err) + return nil, fmt.Errorf("unable to open store/store.go file: %w", err) } src, err := ioutil.ReadAll(file) if err != nil { diff --git a/utils/i18n.go b/utils/i18n.go index 8224a43746..9a9ee00c36 100644 --- a/utils/i18n.go +++ b/utils/i18n.go @@ -54,7 +54,7 @@ func InitTranslations(localizationSettings model.LocalizationSettings) error { func InitTranslationsWithDir(dir string) error { i18nDirectory, found := fileutils.FindDirRelBinary(dir) if !found { - return fmt.Errorf(fmt.Sprintf("Unable to find i18n directory at %q", dir)) + return fmt.Errorf("unable to find i18n directory at %q", dir) } files, _ := ioutil.ReadDir(i18nDirectory) @@ -80,12 +80,12 @@ func GetTranslationsBySystemLocale() (i18n.TranslateFunc, error) { } if locales[locale] == "" { - return nil, fmt.Errorf("Failed to load system translations for '%v'", model.DEFAULT_LOCALE) + return nil, fmt.Errorf("failed to load system translations for '%v'", model.DEFAULT_LOCALE) } translations := TfuncWithFallback(locale) if translations == nil { - return nil, fmt.Errorf("Failed to load system translations") + return nil, fmt.Errorf("failed to load system translations") } mlog.Info("Loaded system translations", mlog.String("for locale", locale), mlog.String("from locale", locales[locale]))