Skip to content

Commit

Permalink
Check error in the same line
Browse files Browse the repository at this point in the history
The patchset follows Go style to check error immediately after calling
the method in the same line.

Change-Id: I20200cff6e7ea6f4bc508e13ea96a24d39de74f2
Signed-off-by: Baohua Yang <yangbaohua@gmail.com>
Signed-off-by: Baohua Yang <baohua.yang@oracle.com>
  • Loading branch information
yeasy authored and denyeart committed Dec 20, 2023
1 parent 3f31810 commit 1b21b0b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions internal/ccmetadata/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ func ValidateMetadataFile(filePathName string, fileBytes []byte) error {
}

// If the file is not valid for the given directory-based validator, return the corresponding error
err := fileValidator(filePathName, fileBytes)
if err != nil {
if err := fileValidator(filePathName, fileBytes); err != nil {
return err
}

Expand Down Expand Up @@ -144,8 +143,7 @@ func couchdbIndexFileValidator(fileName string, fileBytes []byte) error {
}

// validate the index definition
err := validateIndexJSON(indexDefinition)
if err != nil {
if err := validateIndexJSON(indexDefinition); err != nil {
return &InvalidIndexContentError{fmt.Sprintf("Index metadata file [%s] is not a valid index definition: %s", fileName, err)}
}

Expand Down Expand Up @@ -173,8 +171,7 @@ func validateIndexJSON(indexDefinition map[string]interface{}) error {
return fmt.Errorf("Invalid entry, \"index\" must be a JSON")
}

err := processIndexMap(jsonValue.(map[string]interface{}))
if err != nil {
if err := processIndexMap(jsonValue.(map[string]interface{})); err != nil {
return err
}

Expand Down Expand Up @@ -243,8 +240,7 @@ func processIndexMap(jsonFragment map[string]interface{}) error {

case reflect.Map:
// Handle the case where a sort is included ex: {"size":"asc"}, {"color":"desc"}
err := validateFieldMap(itemValue.(map[string]interface{}))
if err != nil {
if err := validateFieldMap(itemValue.(map[string]interface{})); err != nil {
return err
}

Expand Down

0 comments on commit 1b21b0b

Please sign in to comment.