diff --git a/cmd/admin-handlers_test.go b/cmd/admin-handlers_test.go index 7b1a20f99..b3128cfc8 100644 --- a/cmd/admin-handlers_test.go +++ b/cmd/admin-handlers_test.go @@ -1184,7 +1184,7 @@ func TestSetConfigHandler(t *testing.T) { t.Fatalf("Failed to decode set config result json %v", err) } - if result.Status != true { + if !result.Status { t.Error("Expected set-config to succeed, but failed") } } diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 1c6bc67c6..a1d2d4a3d 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -86,10 +86,7 @@ func isBucketActionAllowed(action, bucket, prefix string) bool { resource := bucketARNPrefix + path.Join(bucket, prefix) var conditionKeyMap map[string]set.StringSet // Validate action, resource and conditions with current policy statements. - if !bucketPolicyEvalStatements(action, resource, conditionKeyMap, policy.Statements) { - return false - } - return true + return bucketPolicyEvalStatements(action, resource, conditionKeyMap, policy.Statements) } // GetBucketLocationHandler - GET Bucket location. diff --git a/cmd/bucket-notification-handlers.go b/cmd/bucket-notification-handlers.go index ad4a6333c..96c68cf97 100644 --- a/cmd/bucket-notification-handlers.go +++ b/cmd/bucket-notification-handlers.go @@ -209,10 +209,7 @@ func writeNotification(w http.ResponseWriter, notification map[string][]Notifica _, err = w.Write(append(notificationBytes, crlf...)) // Make sure we have flushed, this would set Transfer-Encoding: chunked. w.(http.Flusher).Flush() - if err != nil { - return err - } - return nil + return err } // CRLF character used for chunked transfer in accordance with HTTP standards. diff --git a/cmd/format-config-v1_test.go b/cmd/format-config-v1_test.go index b92532b0a..b96a83ca0 100644 --- a/cmd/format-config-v1_test.go +++ b/cmd/format-config-v1_test.go @@ -213,9 +213,7 @@ func genFormatXLInvalidDisksOrder() []*formatConfigV1 { } // Re order jbod for failure case. var jbod1 = make([]string, 8) - for i, j := range jbod { - jbod1[i] = j - } + copy(jbod1, jbod) jbod1[1], jbod1[2] = jbod[2], jbod[1] formatConfigs[2].XL.JBOD = jbod1 return formatConfigs @@ -576,9 +574,7 @@ func TestSavedUUIDOrder(t *testing.T) { } // Re order jbod for failure case. var jbod1 = make([]string, 8) - for i, j := range jbod { - jbod1[i] = j - } + copy(jbod1, jbod) jbod1[1], jbod1[2] = jbod[2], jbod[1] formatConfigs[2].XL.JBOD = jbod1 uuidTestCases[1].shouldPass = false diff --git a/cmd/fs-v1-metadata.go b/cmd/fs-v1-metadata.go index f467991db..3f7f1949a 100644 --- a/cmd/fs-v1-metadata.go +++ b/cmd/fs-v1-metadata.go @@ -238,12 +238,9 @@ func saveFormatFS(formatPath string, fsFormat *formatConfigV1) error { } defer lk.Close() - if _, err = lk.Write(metadataBytes); err != nil { - return err - } - + _, err = lk.Write(metadataBytes) // Success. - return nil + return err } // Return if the part info in uploadedParts and completeParts are same. diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 924fba23d..f651a6d52 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -67,12 +67,7 @@ func initMetaVolumeFS(fsPath, fsUUID string) error { } metaMultipartPath := pathJoin(fsPath, minioMetaMultipartBucket) - if err := mkdirAll(metaMultipartPath, 0777); err != nil { - return err - } - - // Return success here. - return nil + return mkdirAll(metaMultipartPath, 0777) } diff --git a/cmd/notifiers.go b/cmd/notifiers.go index 1d3ed1bfd..cbc31e816 100644 --- a/cmd/notifiers.go +++ b/cmd/notifiers.go @@ -98,10 +98,7 @@ func isWebhookQueue(sqsArn arnSQS) bool { return false } rNotify := serverConfig.Notify.GetWebhookByID(sqsArn.AccountID) - if !rNotify.Enable { - return false - } - return true + return rNotify.Enable } // Returns true if queueArn is for an Redis queue. diff --git a/cmd/object-api-common.go b/cmd/object-api-common.go index b5feed0fb..b2fd37af6 100644 --- a/cmd/object-api-common.go +++ b/cmd/object-api-common.go @@ -134,10 +134,7 @@ func isLocalStorage(ep *url.URL) bool { if globalMinioHost != "" && globalMinioPort != "" { // if --address host:port was specified for distXL we short // circuit only the endPoint that matches host:port - if net.JoinHostPort(globalMinioHost, globalMinioPort) == ep.Host { - return true - } - return false + return net.JoinHostPort(globalMinioHost, globalMinioPort) == ep.Host } // Split host to extract host information. host, _, err := net.SplitHostPort(ep.Host) diff --git a/cmd/object_api_suite_test.go b/cmd/object_api_suite_test.go index e3cb467ad..e382af73a 100644 --- a/cmd/object_api_suite_test.go +++ b/cmd/object_api_suite_test.go @@ -243,7 +243,7 @@ func testPaging(obj ObjectLayer, instanceType string, c TestErrHandler) { if len(result.Objects) != 0 { c.Errorf("%s: Number of objects in the result different from expected value.", instanceType) } - if result.IsTruncated != false { + if result.IsTruncated { c.Errorf("%s: Expected IsTruncated to be `false`, but instead found it to be `%v`", instanceType, result.IsTruncated) } @@ -263,7 +263,7 @@ func testPaging(obj ObjectLayer, instanceType string, c TestErrHandler) { if len(result.Objects) != i+1 { c.Errorf("%s: Expected length of objects to be %d, instead found to be %d", instanceType, len(result.Objects), i+1) } - if result.IsTruncated != false { + if result.IsTruncated { c.Errorf("%s: Expected IsTruncated to be `false`, but instead found it to be `%v`", instanceType, result.IsTruncated) } } @@ -282,7 +282,7 @@ func testPaging(obj ObjectLayer, instanceType string, c TestErrHandler) { if len(result.Objects) != 5 { c.Errorf("%s: Expected length of objects to be %d, instead found to be %d", instanceType, 5, len(result.Objects)) } - if result.IsTruncated != true { + if !result.IsTruncated { c.Errorf("%s: Expected IsTruncated to be `true`, but instead found it to be `%v`", instanceType, result.IsTruncated) } } @@ -683,7 +683,7 @@ func testListObjectsTestsForNonExistantBucket(obj ObjectLayer, instanceType stri if len(result.Objects) != 0 { c.Fatalf("%s: Expected number of objects in the result to be `%d`, but instead found `%d`", instanceType, 0, len(result.Objects)) } - if result.IsTruncated != false { + if result.IsTruncated { c.Fatalf("%s: Expected IsTruncated to be `false`, but instead found it to be `%v`", instanceType, result.IsTruncated) } if err.Error() != "Bucket not found: bucket" { diff --git a/cmd/signature-v4-parser_test.go b/cmd/signature-v4-parser_test.go index d30b8bee1..3639c093d 100644 --- a/cmd/signature-v4-parser_test.go +++ b/cmd/signature-v4-parser_test.go @@ -569,7 +569,7 @@ func TestDoesV4PresignParamsExist(t *testing.T) { func TestParsePreSignV4(t *testing.T) { // converts the duration in seconds into string format. getDurationStr := func(expires int) string { - return strconv.FormatInt(int64(expires), 10) + return strconv.Itoa(expires) } // used in expected preSignValues, preSignValues.Date is of type time.Time . queryTime := time.Now().UTC() diff --git a/cmd/test-utils_test.go b/cmd/test-utils_test.go index 7d518f267..efaa6dd7d 100644 --- a/cmd/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -1690,9 +1690,7 @@ func removeDiskN(disks []string, n int) { // Makes a entire new copy of a StorageAPI slice. func deepCopyStorageDisks(storageDisks []StorageAPI) []StorageAPI { newStorageDisks := make([]StorageAPI, len(storageDisks)) - for i, disk := range storageDisks { - newStorageDisks[i] = disk - } + copy(newStorageDisks, storageDisks) return newStorageDisks } diff --git a/cmd/web-handlers_test.go b/cmd/web-handlers_test.go index b3e4f83b5..64b24fa31 100644 --- a/cmd/web-handlers_test.go +++ b/cmd/web-handlers_test.go @@ -696,7 +696,7 @@ func testUploadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler t.Fatalf("Failed, %v", err) } - if bytes.Compare(byteBuffer.Bytes(), content) != 0 { + if !bytes.Equal(byteBuffer.Bytes(), content) { t.Fatalf("The upload file is different from the download file") } @@ -782,7 +782,7 @@ func testDownloadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandl t.Fatalf("Expected the response status to be 200, but instead found `%d`", code) } - if bytes.Compare(bodyContent, content) != 0 { + if !bytes.Equal(bodyContent, content) { t.Fatalf("The downloaded file is corrupted") } @@ -805,7 +805,7 @@ func testDownloadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandl t.Fatalf("Expected the response status to be 200, but instead found `%d`", code) } - if bytes.Compare(bodyContent, content) != 0 { + if !bytes.Equal(bodyContent, content) { t.Fatalf("The downloaded file is corrupted") } } diff --git a/cmd/xl-v1-list-objects-heal.go b/cmd/xl-v1-list-objects-heal.go index 2fcb02c3c..d48470974 100644 --- a/cmd/xl-v1-list-objects-heal.go +++ b/cmd/xl-v1-list-objects-heal.go @@ -133,7 +133,7 @@ func (xl xlObjects) listObjectsHeal(bucket, prefix, marker, delimiter string, ma nextMarker = objInfo.Name objInfos = append(objInfos, objInfo) i++ - if walkResult.end == true { + if walkResult.end { eof = true break } diff --git a/cmd/xl-v1.go b/cmd/xl-v1.go index afba095a6..147a0411d 100644 --- a/cmd/xl-v1.go +++ b/cmd/xl-v1.go @@ -161,12 +161,7 @@ func newXLObjects(storageDisks []StorageAPI) (ObjectLayer, error) { xl.writeQuorum = writeQuorum // Do a quick heal on the buckets themselves for any discrepancies. - if err := quickHeal(xl.storageDisks, xl.writeQuorum, xl.readQuorum); err != nil { - return xl, err - } - - // Return successfully initialized object layer. - return xl, nil + return xl, quickHeal(xl.storageDisks, xl.writeQuorum, xl.readQuorum) } // Shutdown function for object storage interface.