resource/resource_list.go
File `resource_list.go` has 1234 lines of code (exceeds 500 allowed). Consider refactoring.// This file was automatically generated by genny.// Any changes will be lost if this file is regenerated.// see https://github.com/cheekybits/genny package resource import ( "encoding/json" "fmt" "reflect" "strings" "github.com/SimonBaeumer/goss/system" "github.com/SimonBaeumer/goss/util") //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type AddrMap map[string]*Addr var BlacklistedAutoAddHeaders = [...]string{"Set-Cookie", "set-cookie", "Date", "date"} Similar blocks of code found in 14 locations. Consider refactoring.func (r AddrMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Addr, error) { sysres := sys.NewAddr(sr, sys, config) res, err := NewAddr(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r AddrMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Addr, system.Addr, bool) { sysres := sys.NewAddr(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewAddr(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `AddrMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *AddrMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Addr{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Addr if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `AddrMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *AddrMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Addr{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Addr if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type CommandMap map[string]*Command Similar blocks of code found in 14 locations. Consider refactoring.func (r CommandMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Command, error) { sysres := sys.NewCommand(sr, sys, config) res, err := NewCommand(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r CommandMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Command, system.Command, bool) { sysres := sys.NewCommand(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewCommand(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `CommandMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *CommandMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Command{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Command if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `CommandMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *CommandMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Command{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Command if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type DNSMap map[string]*DNS Similar blocks of code found in 14 locations. Consider refactoring.func (r DNSMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*DNS, error) { sysres := sys.NewDNS(sr, sys, config) res, err := NewDNS(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r DNSMap) AppendSysResourceIfExists(sr string, sys *system.System) (*DNS, system.DNS, bool) { sysres := sys.NewDNS(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewDNS(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `DNSMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *DNSMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := DNS{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*DNS if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `DNSMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *DNSMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := DNS{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*DNS if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type FileMap map[string]*File Similar blocks of code found in 14 locations. Consider refactoring.func (r FileMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*File, error) { sysres := sys.NewFile(sr, sys, config) res, err := NewFile(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r FileMap) AppendSysResourceIfExists(sr string, sys *system.System) (*File, system.File, bool) { sysres := sys.NewFile(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewFile(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `FileMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *FileMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := File{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*File if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `FileMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *FileMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := File{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*File if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type GossfileMap map[string]*Gossfile Similar blocks of code found in 14 locations. Consider refactoring.func (r GossfileMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Gossfile, error) { sysres := sys.NewGossfile(sr, sys, config) res, err := NewGossfile(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r GossfileMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Gossfile, system.Gossfile, bool) { sysres := sys.NewGossfile(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewGossfile(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `GossfileMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *GossfileMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Gossfile{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Gossfile if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `GossfileMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *GossfileMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Gossfile{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Gossfile if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type GroupMap map[string]*Group Similar blocks of code found in 14 locations. Consider refactoring.func (r GroupMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Group, error) { sysres := sys.NewGroup(sr, sys, config) res, err := NewGroup(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r GroupMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Group, system.Group, bool) { sysres := sys.NewGroup(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewGroup(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `GroupMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *GroupMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Group{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Group if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `GroupMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *GroupMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Group{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Group if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type PackageMap map[string]*Package func (r PackageMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Package, error) { sysres := sys.NewPackage(sr, "") res, err := NewPackage(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} func (r PackageMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Package, system.Package, bool) { sysres := sys.NewPackage(sr, "") // FIXME: Do we want to be silent about errors? res, _ := NewPackage(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `PackageMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *PackageMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Package{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Package if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `PackageMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *PackageMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Package{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Package if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type PortMap map[string]*Port Similar blocks of code found in 14 locations. Consider refactoring.func (r PortMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Port, error) { sysres := sys.NewPort(sr, sys, config) res, err := NewPort(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r PortMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Port, system.Port, bool) { sysres := sys.NewPort(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewPort(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `PortMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *PortMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Port{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Port if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `PortMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *PortMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Port{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Port if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type ProcessMap map[string]*Process Similar blocks of code found in 14 locations. Consider refactoring.func (r ProcessMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Process, error) { sysres := sys.NewProcess(sr, sys, config) res, err := NewProcess(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r ProcessMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Process, system.Process, bool) { sysres := sys.NewProcess(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewProcess(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `ProcessMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *ProcessMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Process{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Process if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `ProcessMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *ProcessMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Process{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Process if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type ServiceMap map[string]*Service Similar blocks of code found in 14 locations. Consider refactoring.func (r ServiceMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Service, error) { sysres := sys.NewService(sr, sys, config) res, err := NewService(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r ServiceMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Service, system.Service, bool) { sysres := sys.NewService(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewService(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `ServiceMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *ServiceMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Service{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Service if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `ServiceMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *ServiceMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Service{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Service if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type UserMap map[string]*User Similar blocks of code found in 14 locations. Consider refactoring.func (r UserMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*User, error) { sysres := sys.NewUser(sr, sys, config) res, err := NewUser(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r UserMap) AppendSysResourceIfExists(sr string, sys *system.System) (*User, system.User, bool) { sysres := sys.NewUser(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewUser(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `UserMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *UserMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := User{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*User if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `UserMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *UserMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := User{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*User if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type KernelParamMap map[string]*KernelParam Similar blocks of code found in 14 locations. Consider refactoring.func (r KernelParamMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*KernelParam, error) { sysres := sys.NewKernelParam(sr, sys, config) res, err := NewKernelParam(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r KernelParamMap) AppendSysResourceIfExists(sr string, sys *system.System) (*KernelParam, system.KernelParam, bool) { sysres := sys.NewKernelParam(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewKernelParam(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `KernelParamMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *KernelParamMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := KernelParam{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*KernelParam if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `KernelParamMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *KernelParamMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := KernelParam{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*KernelParam if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type MountMap map[string]*Mount Similar blocks of code found in 14 locations. Consider refactoring.func (r MountMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Mount, error) { sysres := sys.NewMount(sr, sys, config) res, err := NewMount(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r MountMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Mount, system.Mount, bool) { sysres := sys.NewMount(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewMount(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `MountMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *MountMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Mount{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Mount if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `MountMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *MountMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Mount{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Mount if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type InterfaceMap map[string]*Interface Similar blocks of code found in 14 locations. Consider refactoring.func (r InterfaceMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Interface, error) { sysres := sys.NewInterface(sr, sys, config) res, err := NewInterface(sysres, config) if err != nil { return nil, err } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} Similar blocks of code found in 15 locations. Consider refactoring.func (r InterfaceMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Interface, system.Interface, bool) { sysres := sys.NewInterface(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewInterface(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `InterfaceMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *InterfaceMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := Interface{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Interface if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `InterfaceMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *InterfaceMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := Interface{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*Interface if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} //go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go//go:generate goimports -w resource_list.go resource_list.go type HTTPMap map[string]*HTTP func (r HTTPMap) AppendSysResource(src string, sys *system.System, config util.Config) (*HTTP, error) { sysres := sys.NewHTTP(src, sys, config) res, err := NewHTTP(sysres, config) if err != nil { return nil, err } // Remove headers because of the instability of the generated data res.Headers = config.Header if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, nil} func (r HTTPMap) isBlacklistedHeader(key string) bool { for _, listedKey := range BlacklistedAutoAddHeaders { if listedKey == key { return true } } return false} Similar blocks of code found in 15 locations. Consider refactoring.func (r HTTPMap) AppendSysResourceIfExists(sr string, sys *system.System) (*HTTP, system.HTTP, bool) { sysres := sys.NewHTTP(sr, sys, util.Config{}) // FIXME: Do we want to be silent about errors? res, _ := NewHTTP(sysres, util.Config{}) if e, _ := sysres.Exists(); e != true { return res, sysres, false } if old_res, ok := r[res.ID()]; ok { res.Title = old_res.Title res.Meta = old_res.Meta } r[res.ID()] = res return res, sysres, true} Method `HTTPMap.UnmarshalJSON` has 7 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *HTTPMap) UnmarshalJSON(data []byte) error { // Curried json.Unmarshal unmarshal := func(i interface{}) error { if err := json.Unmarshal(data, i); err != nil { return err } return nil } // Validate configuration zero := HTTP{} whitelist, err := util.WhitelistAttrs(zero, util.JSON) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*HTTP if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil} Method `HTTPMap.UnmarshalYAML` has 5 return statements (exceeds 4 allowed).
Similar blocks of code found in 17 locations. Consider refactoring.func (ret *HTTPMap) UnmarshalYAML(unmarshal func(v interface{}) error) error { // Validate configuration zero := HTTP{} whitelist, err := util.WhitelistAttrs(zero, util.YAML) if err != nil { return err } if err := util.ValidateSections(unmarshal, zero, whitelist); err != nil { return err } var tmp map[string]*HTTP if err := unmarshal(&tmp); err != nil { return err } typ := reflect.TypeOf(zero) typs := strings.Split(typ.String(), ".")[1] for id, res := range tmp { if res == nil { return fmt.Errorf("Could not parse resource %s:%s", typs, id) } res.SetID(id) } *ret = tmp return nil}