NO-TCIKET fix bad smells - error strings should not be capitalized (#16930)

Automatic Merge
Этот коммит содержится в:
Atanas Alexandrov
2021-02-23 06:22:27 +01:00
коммит произвёл GitHub
родитель 30b0523983
Коммит e44190f4cc
9 изменённых файлов: 28 добавлений и 28 удалений

Просмотреть файл

@@ -307,18 +307,18 @@ func (a *App) getBuiltinDynamicListArgument(commandArgs *model.CommandArgs, arg
dynamicArg := arg.Data.(*model.AutocompleteDynamicListArg) dynamicArg := arg.Data.(*model.AutocompleteDynamicListArg)
arr := strings.Split(dynamicArg.FetchURL, ":") arr := strings.Split(dynamicArg.FetchURL, ":")
if len(arr) < 2 { 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] cmdName := arr[1]
provider := GetCommandProvider(cmdName) provider := GetCommandProvider(cmdName)
if provider == nil { 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) dp, ok := provider.(AutocompleteDynamicArgProvider)
if !ok { 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) return dp.GetAutoCompleteListItems(a, commandArgs, arg, parsed, toBeParsed)

Просмотреть файл

@@ -278,11 +278,12 @@ func TestCreateZipFileAndAddFiles(t *testing.T) {
defer th.TearDown() defer th.TearDown()
mockBackend := mocks.FileBackend{} 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") 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 = mocks.FileBackend{}
mockBackend.On("WriteFile", mock.Anything, "directory-to-heaven/zip-file-name-to-heaven.zip").Return(int64(666), nil) mockBackend.On("WriteFile", mock.Anything, "directory-to-heaven/zip-file-name-to-heaven.zip").Return(int64(666), nil)

Просмотреть файл

@@ -160,7 +160,7 @@ func extractStoreMetadata() (*storeMetadata, error) {
file, err := os.Open(inputFile) file, err := os.Open(inputFile)
if err != nil { 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) src, err := ioutil.ReadAll(file)
if err != nil { if err != nil {

Просмотреть файл

@@ -436,7 +436,7 @@ func (s *apiRPCServer) PluginHTTP(args *Z_PluginHTTPArgs, returns *Z_PluginHTTPR
returns.Response = response returns.Response = response
returns.ResponseBody = responseBody returns.ResponseBody = responseBody
} else { } else {
return encodableError(fmt.Errorf("API PluginHTTP called but not implemented.")) return encodableError(fmt.Errorf("API PluginHTTP called but not implemented"))
} }
return nil return nil
} }
@@ -524,7 +524,7 @@ func (s *hooksRPCServer) FileWillBeUploaded(args *Z_FileWillBeUploadedArgs, retu
}); ok { }); ok {
returns.A, returns.B = hook.FileWillBeUploaded(args.A, args.B, fileReader, returnFileWriter) returns.A, returns.B = hook.FileWillBeUploaded(args.A, args.B, fileReader, returnFileWriter)
} else { } else {
return fmt.Errorf("Hook FileWillBeUploaded called but not implemented.") return fmt.Errorf("hook FileWillBeUploaded called but not implemented")
} }
return nil return nil
} }
@@ -564,7 +564,7 @@ func (s *hooksRPCServer) MessageWillBePosted(args *Z_MessageWillBePostedArgs, re
returns.A, returns.B = hook.MessageWillBePosted(args.A, args.B) returns.A, returns.B = hook.MessageWillBePosted(args.A, args.B)
} else { } else {
return encodableError(fmt.Errorf("Hook MessageWillBePosted called but not implemented.")) return encodableError(fmt.Errorf("hook MessageWillBePosted called but not implemented"))
} }
return nil 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) returns.A, returns.B = hook.MessageWillBeUpdated(args.A, args.B, args.C)
} else { } else {
return encodableError(fmt.Errorf("Hook MessageWillBeUpdated called but not implemented.")) return encodableError(fmt.Errorf("hook MessageWillBeUpdated called but not implemented"))
} }
return nil return nil
} }
@@ -634,7 +634,7 @@ func (s *apiRPCServer) LogDebug(args *Z_LogDebugArgs, returns *Z_LogDebugReturns
}); ok { }); ok {
hook.LogDebug(args.A, args.B...) hook.LogDebug(args.A, args.B...)
} else { } else {
return encodableError(fmt.Errorf("API LogDebug called but not implemented.")) return encodableError(fmt.Errorf("API LogDebug called but not implemented"))
} }
return nil return nil
} }
@@ -663,7 +663,7 @@ func (s *apiRPCServer) LogInfo(args *Z_LogInfoArgs, returns *Z_LogInfoReturns) e
}); ok { }); ok {
hook.LogInfo(args.A, args.B...) hook.LogInfo(args.A, args.B...)
} else { } else {
return encodableError(fmt.Errorf("API LogInfo called but not implemented.")) return encodableError(fmt.Errorf("API LogInfo called but not implemented"))
} }
return nil return nil
} }
@@ -692,7 +692,7 @@ func (s *apiRPCServer) LogWarn(args *Z_LogWarnArgs, returns *Z_LogWarnReturns) e
}); ok { }); ok {
hook.LogWarn(args.A, args.B...) hook.LogWarn(args.A, args.B...)
} else { } else {
return encodableError(fmt.Errorf("API LogWarn called but not implemented.")) return encodableError(fmt.Errorf("API LogWarn called but not implemented"))
} }
return nil return nil
} }
@@ -720,7 +720,7 @@ func (s *apiRPCServer) LogError(args *Z_LogErrorArgs, returns *Z_LogErrorReturns
}); ok { }); ok {
hook.LogError(args.A, args.B...) hook.LogError(args.A, args.B...)
} else { } else {
return encodableError(fmt.Errorf("API LogError called but not implemented.")) return encodableError(fmt.Errorf("API LogError called but not implemented"))
} }
return nil 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) InstallPlugin(file io.Reader, replace bool) (*model.Manifest, *model.AppError)
}) })
if !ok { 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) receivePluginConnection, err := s.muxBroker.Dial(args.PluginStreamID)

Просмотреть файл

@@ -122,8 +122,7 @@ func (sup *supervisor) PerformHealthCheck() error {
} }
} }
if pingErr != nil { 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")
} }
} }

Просмотреть файл

@@ -37,7 +37,7 @@ func (de *documentExtractor) Extract(filename string, r io.Reader) (string, erro
extension := strings.TrimPrefix(path.Ext(filename), ".") extension := strings.TrimPrefix(path.Ext(filename), ".")
converter, ok := doconvConverterByExtensions[extension] converter, ok := doconvConverterByExtensions[extension]
if !ok { if !ok {
return "", errors.New("Unknown converter") return "", errors.New("unknown converter")
} }
f, err := ioutil.TempFile(os.TempDir(), "docconv") f, err := ioutil.TempFile(os.TempDir(), "docconv")

Просмотреть файл

@@ -70,19 +70,19 @@ func GetMailBox(email string) (results JSONMessageHeaderInbucket, err error) {
}() }()
if resp.Body == nil { if resp.Body == nil {
return nil, fmt.Errorf("No Mailbox") return nil, fmt.Errorf("no mailbox")
} }
var record JSONMessageHeaderInbucket var record JSONMessageHeaderInbucket
err = json.NewDecoder(resp.Body).Decode(&record) err = json.NewDecoder(resp.Body).Decode(&record)
switch { switch {
case err == io.EOF: case err == io.EOF:
return nil, fmt.Errorf("Error: %s", err) return nil, fmt.Errorf("error: %s", err)
case err != nil: case err != nil:
return nil, fmt.Errorf("Error: %s", err) return nil, fmt.Errorf("error: %s", err)
} }
if len(record) == 0 { if len(record) == 0 {
return nil, fmt.Errorf("No mailbox") return nil, fmt.Errorf("no mailbox")
} }
return record, nil return record, nil
@@ -171,7 +171,7 @@ func RetryInbucket(attempts int, callback func() error) (err error) {
fmt.Println("retrying...") 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) { func getInbucketHost() (host string) {

Просмотреть файл

@@ -153,7 +153,7 @@ func extractStoreMetadata() (*storeMetadata, error) {
file, err := os.Open("store.go") file, err := os.Open("store.go")
if err != nil { 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) src, err := ioutil.ReadAll(file)
if err != nil { if err != nil {

Просмотреть файл

@@ -54,7 +54,7 @@ func InitTranslations(localizationSettings model.LocalizationSettings) error {
func InitTranslationsWithDir(dir string) error { func InitTranslationsWithDir(dir string) error {
i18nDirectory, found := fileutils.FindDirRelBinary(dir) i18nDirectory, found := fileutils.FindDirRelBinary(dir)
if !found { 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) files, _ := ioutil.ReadDir(i18nDirectory)
@@ -80,12 +80,12 @@ func GetTranslationsBySystemLocale() (i18n.TranslateFunc, error) {
} }
if locales[locale] == "" { 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) translations := TfuncWithFallback(locale)
if translations == nil { 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])) mlog.Info("Loaded system translations", mlog.String("for locale", locale), mlog.String("from locale", locales[locale]))