From 9ec575b164edd67715dd267308baac00e44cb02d Mon Sep 17 00:00:00 2001 From: Alexandros Filios Date: Tue, 26 Jul 2022 12:52:17 +0200 Subject: [PATCH] Reduce staticcheck warnings (ST1005) As part of issue #50, removed warnings related to: * ST1005: error string format Signed-off-by: Alexandros Filios --- integration/nwo/cmd/cryptogen/cryptogen.go | 10 +++++----- .../fabric/packager/ccmetadata/validators.go | 20 +++++++++---------- .../nwo/fabric/packager/golang/platform.go | 4 ++-- .../view/core/config/viper/config_util.go | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/integration/nwo/cmd/cryptogen/cryptogen.go b/integration/nwo/cmd/cryptogen/cryptogen.go index 2731800da..a79f476d4 100644 --- a/integration/nwo/cmd/cryptogen/cryptogen.go +++ b/integration/nwo/cmd/cryptogen/cryptogen.go @@ -206,14 +206,14 @@ func getConfig() (*Config, error) { if genConfigFile != "" { data, err := ioutil.ReadFile(genConfigFile) if err != nil { - return nil, fmt.Errorf("Error reading configuration: %s", err) + return nil, fmt.Errorf("error reading configuration: %s", err) } configData = string(data) } else if extConfigFile != "" { data, err := ioutil.ReadFile(extConfigFile) if err != nil { - return nil, fmt.Errorf("Error reading configuration: %s", err) + return nil, fmt.Errorf("error reading configuration: %s", err) } configData = string(data) @@ -224,7 +224,7 @@ func getConfig() (*Config, error) { config := &Config{} err := yaml.Unmarshal([]byte(configData), &config) if err != nil { - return nil, fmt.Errorf("Error Unmarshaling YAML: %s", err) + return nil, fmt.Errorf("error Unmarshaling YAML: %s", err) } return config, nil @@ -383,13 +383,13 @@ func parseTemplate(input string, data interface{}) (string, error) { t, err := template.New("parse").Parse(input) if err != nil { - return "", fmt.Errorf("Error parsing template: %s", err) + return "", fmt.Errorf("error parsing template: %s", err) } output := new(bytes.Buffer) err = t.Execute(output, data) if err != nil { - return "", fmt.Errorf("Error executing template: %s", err) + return "", fmt.Errorf("error executing template: %s", err) } return output.String(), nil diff --git a/integration/nwo/fabric/packager/ccmetadata/validators.go b/integration/nwo/fabric/packager/ccmetadata/validators.go index 902a426d7..67b618257 100644 --- a/integration/nwo/fabric/packager/ccmetadata/validators.go +++ b/integration/nwo/fabric/packager/ccmetadata/validators.go @@ -176,7 +176,7 @@ func validateIndexJSON(indexDefinition map[string]interface{}) error { case "index": if reflect.TypeOf(jsonValue).Kind() != reflect.Map { - return fmt.Errorf("Invalid entry, \"index\" must be a JSON") + return fmt.Errorf("invalid entry, \"index\" must be a JSON") } err := processIndexMap(jsonValue.(map[string]interface{})) @@ -190,7 +190,7 @@ func validateIndexJSON(indexDefinition map[string]interface{}) error { //Verify the design doc is a string if reflect.TypeOf(jsonValue).Kind() != reflect.String { - return fmt.Errorf("Invalid entry, \"ddoc\" must be a string") + return fmt.Errorf("invalid entry, \"ddoc\" must be a string") } logger.Debugf("Found index object: \"%s\":\"%s\"", jsonKey, jsonValue) @@ -199,7 +199,7 @@ func validateIndexJSON(indexDefinition map[string]interface{}) error { //Verify the name is a string if reflect.TypeOf(jsonValue).Kind() != reflect.String { - return fmt.Errorf("Invalid entry, \"name\" must be a string") + return fmt.Errorf("invalid entry, \"name\" must be a string") } logger.Debugf("Found index object: \"%s\":\"%s\"", jsonKey, jsonValue) @@ -207,21 +207,21 @@ func validateIndexJSON(indexDefinition map[string]interface{}) error { case "type": if jsonValue != "json" { - return fmt.Errorf("Index type must be json") + return fmt.Errorf("index type must be json") } logger.Debugf("Found index object: \"%s\":\"%s\"", jsonKey, jsonValue) default: - return fmt.Errorf("Invalid Entry. Entry %s", jsonKey) + return fmt.Errorf("invalid Entry. Entry %s", jsonKey) } } if !indexIncluded { - return fmt.Errorf("Index definition must include a \"fields\" definition") + return fmt.Errorf("index definition must include a \"fields\" definition") } return nil @@ -263,7 +263,7 @@ func processIndexMap(jsonFragment map[string]interface{}) error { } default: - return fmt.Errorf("Expecting a JSON array of fields") + return fmt.Errorf("expecting a JSON array of fields") } case "partial_filter_selector": @@ -275,7 +275,7 @@ func processIndexMap(jsonFragment map[string]interface{}) error { //if anything other than "fields" or "partial_filter_selector" was found, //return an error - return fmt.Errorf("Invalid Entry. Entry %s", jsonKey) + return fmt.Errorf("invalid Entry. Entry %s", jsonKey) } @@ -297,12 +297,12 @@ func validateFieldMap(jsonFragment map[string]interface{}) error { //Ensure the sort is either "asc" or "desc" jv := strings.ToLower(jsonValue) if jv != "asc" && jv != "desc" { - return fmt.Errorf("Sort must be either \"asc\" or \"desc\". \"%s\" was found.", jsonValue) + return fmt.Errorf("sort must be either \"asc\" or \"desc\". \"%s\" was found", jsonValue) } logger.Debugf("Found index field name: \"%s\":\"%s\"", jsonKey, jsonValue) default: - return fmt.Errorf("Invalid field definition, fields must be in the form \"fieldname\":\"sort\"") + return fmt.Errorf("invalid field definition, fields must be in the form \"fieldname\":\"sort\"") } } diff --git a/integration/nwo/fabric/packager/golang/platform.go b/integration/nwo/fabric/packager/golang/platform.go index 37bf4925e..771474e0d 100644 --- a/integration/nwo/fabric/packager/golang/platform.go +++ b/integration/nwo/fabric/packager/golang/platform.go @@ -179,12 +179,12 @@ func (p *Platform) GetDeploymentPayload(codepath string, replacer replacer.Func) if len(raw) != 0 { if err := WriteBytesToPackage(raw, file.Path, file.Name, tw); err != nil { - return nil, fmt.Errorf("Error writing %s to tar: %s", file.Name, err) + return nil, fmt.Errorf("error writing %s to tar: %s", file.Name, err) } } else { err = util.WriteFileToPackage(file.Path, file.Name, tw) if err != nil { - return nil, fmt.Errorf("Error writing %s to tar: %s", file.Name, err) + return nil, fmt.Errorf("error writing %s to tar: %s", file.Name, err) } } } diff --git a/platform/view/core/config/viper/config_util.go b/platform/view/core/config/viper/config_util.go index c7181ea0c..c24a1b1fa 100644 --- a/platform/view/core/config/viper/config_util.go +++ b/platform/view/core/config/viper/config_util.go @@ -103,7 +103,7 @@ func stringFromFileDecodeHook(f reflect.Kind, t reflect.Kind, data interface{}) return string(bytes), nil case ok: // fileName was nil - return nil, fmt.Errorf("Value of File: was nil") + return nil, fmt.Errorf("value of File: was nil") } } return data, nil @@ -161,7 +161,7 @@ func pemBlocksFromFileDecodeHook(f reflect.Kind, t reflect.Kind, data interface{ return result, nil case ok: // fileName was nil - return nil, fmt.Errorf("Value of File: was nil") + return nil, fmt.Errorf("value of File: was nil") } } return data, nil