cleanup: All conditionals simplified under pkg. (#3875)

Address all the changes reported/recommended by
`gosimple` tool.
master
Harshavardhana 8 years ago committed by GitHub
parent 43317530d5
commit 85cbd875fc
  1. 2
      pkg/disk/type_linux.go
  2. 9
      pkg/madmin/api.go
  3. 5
      pkg/madmin/heal-commands.go
  4. 4
      pkg/mimedb/db_test.go
  5. 9
      pkg/quick/encoding.go

@ -40,7 +40,7 @@ var fsType2StringMap = map[string]string{
func getFSType(ftype int64) string {
fsTypeHex := strconv.FormatInt(ftype, 16)
fsTypeString, ok := fsType2StringMap[fsTypeHex]
if ok == false {
if !ok {
return "UNKNOWN"
}
return fsTypeString

@ -1,5 +1,5 @@
/*
* Minio Cloud Storage, (C) 2016 Minio, Inc.
* Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -276,12 +276,7 @@ func (c AdminClient) dumpHTTP(req *http.Request, resp *http.Response) error {
// Ends the http dump.
_, err = fmt.Fprintln(c.traceOutput, "---------END-HTTP---------")
if err != nil {
return err
}
// Returns success.
return nil
return err
}
// do - execute http request.

@ -211,10 +211,7 @@ func (adm *AdminClient) listObjectsHeal(bucket, prefix, marker, delimiter string
}
err = xml.NewDecoder(resp.Body).Decode(&toBeHealedObjects)
if err != nil {
return toBeHealedObjects, err
}
return toBeHealedObjects, nil
return toBeHealedObjects, err
}
// ListObjectsHeal - Lists upto maxKeys objects that needing heal matching bucket, prefix, marker, delimiter.

@ -1,5 +1,5 @@
/*
* mime-db: Mime Database, (C) 2015, 2016 Minio, Inc.
* mime-db: Mime Database, (C) 2015, 2016, 2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ func TestMimeLookup(t *testing.T) {
t.Fatalf("Invalid content type are found expected \"application/x-msdownload\", got %s", contentType)
}
compressible := DB["txt"].Compressible
if compressible != false {
if compressible {
t.Fatalf("Invalid content type are found expected \"false\", got %t", compressible)
}
}

@ -122,8 +122,7 @@ func saveFileConfig(filename string, v interface{}) error {
// decoder format according to the filename extension. If no
// extension is provided, json will be selected by default.
func loadFileConfig(filename string, v interface{}) error {
_, err := os.Stat(filename)
if err != nil {
if _, err := os.Stat(filename); err != nil {
return err
}
fileData, err := ioutil.ReadFile(filename)
@ -133,10 +132,6 @@ func loadFileConfig(filename string, v interface{}) error {
if runtime.GOOS == "windows" {
fileData = []byte(strings.Replace(string(fileData), "\r\n", "\n", -1))
}
ext := filepath.Ext(filename)
// Unmarshal file's content
if err := toUnmarshaller(ext)(fileData, v); err != nil {
return err
}
return nil
return toUnmarshaller(filepath.Ext(filename))(fileData, v)
}

Loading…
Cancel
Save