Skip to content

Commit

Permalink
Reduce staticcheck warnings (ST1005)
Browse files Browse the repository at this point in the history
As part of issue hyperledger-labs#50, removed warnings related to:
* ST1005: error string format

Signed-off-by: Alexandros Filios <alexandros.filios@ibm.com>
  • Loading branch information
alexandrosfilios authored and mbrandenburger committed Jul 26, 2022
1 parent 3234fb0 commit 9ec575b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions integration/nwo/cmd/cryptogen/cryptogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions integration/nwo/fabric/packager/ccmetadata/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}))
Expand All @@ -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)
Expand All @@ -199,29 +199,29 @@ 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)

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
Expand Down Expand Up @@ -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":
Expand All @@ -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)

}

Expand All @@ -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\"")
}
}

Expand Down
4 changes: 2 additions & 2 deletions integration/nwo/fabric/packager/golang/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions platform/view/core/config/viper/config_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ec575b

Please sign in to comment.