Merge pull request #672 from sierraechobravo/master

fix go report card issues
main
Jesse Szwedko 7 years ago committed by GitHub
commit 2997500ba5

@ -22,15 +22,15 @@ func nestedVal(name string, tree map[interface{}]interface{}) (interface{}, bool
if sections := strings.Split(name, "."); len(sections) > 1 { if sections := strings.Split(name, "."); len(sections) > 1 {
node := tree node := tree
for _, section := range sections[:len(sections)-1] { for _, section := range sections[:len(sections)-1] {
if child, ok := node[section]; !ok { child, ok := node[section]
if !ok {
return nil, false return nil, false
} else {
if ctype, ok := child.(map[interface{}]interface{}); !ok {
return nil, false
} else {
node = ctype
}
} }
ctype, ok := child.(map[interface{}]interface{})
if !ok {
return nil, false
}
node = ctype
} }
if val, ok := node[sections[len(sections)-1]]; ok { if val, ok := node[sections[len(sections)-1]]; ok {
return val, true return val, true

@ -66,9 +66,9 @@ func unmarshalMap(i interface{}) (ret map[interface{}]interface{}, err error) {
return ret, nil return ret, nil
} }
func (self *tomlMap) UnmarshalTOML(i interface{}) error { func (tm *tomlMap) UnmarshalTOML(i interface{}) error {
if tmp, err := unmarshalMap(i); err == nil { if tmp, err := unmarshalMap(i); err == nil {
self.Map = tmp tm.Map = tmp
} else { } else {
return err return err
} }

@ -86,7 +86,7 @@ func loadDataFrom(filePath string) ([]byte, error) {
return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath) return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath)
} }
return ioutil.ReadFile(filePath) return ioutil.ReadFile(filePath)
} else {
return nil, fmt.Errorf("unable to determine how to load from path %s", filePath)
} }
return nil, fmt.Errorf("unable to determine how to load from path %s", filePath)
} }

@ -491,7 +491,7 @@ func HandleAction(action interface{}, context *Context) (err error) {
} else if a, ok := action.(func(*Context)); ok { // deprecated function signature } else if a, ok := action.(func(*Context)); ok { // deprecated function signature
a(context) a(context)
return nil return nil
} else {
return errInvalidActionType
} }
return errInvalidActionType
} }

@ -497,7 +497,6 @@ func TestApp_Float64Flag(t *testing.T) {
} }
func TestApp_ParseSliceFlags(t *testing.T) { func TestApp_ParseSliceFlags(t *testing.T) {
var parsedOption, firstArg string
var parsedIntSlice []int var parsedIntSlice []int
var parsedStringSlice []string var parsedStringSlice []string
@ -511,8 +510,6 @@ func TestApp_ParseSliceFlags(t *testing.T) {
Action: func(c *Context) error { Action: func(c *Context) error {
parsedIntSlice = c.IntSlice("p") parsedIntSlice = c.IntSlice("p")
parsedStringSlice = c.StringSlice("ip") parsedStringSlice = c.StringSlice("ip")
parsedOption = c.String("option")
firstArg = c.Args().First()
return nil return nil
}, },
} }

@ -73,7 +73,7 @@ func (c *Context) IsSet(name string) bool {
// change in version 2 to add `IsSet` to the Flag interface to push the // change in version 2 to add `IsSet` to the Flag interface to push the
// responsibility closer to where the information required to determine // responsibility closer to where the information required to determine
// whether a flag is set by non-standard means such as environment // whether a flag is set by non-standard means such as environment
// variables is avaliable. // variables is available.
// //
// See https://github.com/urfave/cli/issues/294 for additional discussion // See https://github.com/urfave/cli/issues/294 for additional discussion
flags := c.Command.Flags flags := c.Command.Flags

Loading…
Cancel
Save