Showing 33 of 439 total issues
Function main
has 321 lines of code (exceeds 50 allowed). Consider refactoring. Open
func main() {
startTime := time.Now()
app := cli.NewApp()
app.EnableBashCompletion = true
app.Version = version
Function ValidateContains
has 125 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ValidateContains(res ResourceRead, property string, expectedValues []string, method func() (io.Reader, error), skip bool) TestResult {
id := res.ID()
title := res.GetTitle()
meta := res.GetMeta()
typ := reflect.TypeOf(res)
Function matcherToGomegaMatcher
has 101 lines of code (exceeds 50 allowed). Consider refactoring. Open
func matcherToGomegaMatcher(matcher interface{}) (types.GomegaMatcher, error) {
switch x := matcher.(type) {
case string, int, bool, float64:
return gomega.Equal(x), nil
case []interface{}:
Function AddResource
has 95 lines of code (exceeds 50 allowed). Consider refactoring. Open
func AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config, sys *system.System) error {
// Need to figure out a good way to refactor this
switch resourceName {
case "Addr":
res, err := gossConfig.Addrs.AppendSysResource(key, sys, config)
Function matcherToGomegaMatcher
has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring. Open
func matcherToGomegaMatcher(matcher interface{}) (types.GomegaMatcher, error) {
switch x := matcher.(type) {
case string, int, bool, float64:
return gomega.Equal(x), nil
case []interface{}:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ValidateValue
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ValidateValue(res ResourceRead, property string, expectedValue interface{}, actual interface{}, skip bool) TestResult {
id := res.ID()
title := res.GetTitle()
meta := res.GetMeta()
typ := reflect.TypeOf(res)
Function AddResource
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
func AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config, sys *system.System) error {
// Need to figure out a good way to refactor this
switch resourceName {
case "Addr":
res, err := gossConfig.Addrs.AppendSysResource(key, sys, config)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function AutoAddResource
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func AutoAddResource(fileName string, gossConfig GossConfig, key string, sys *system.System) error {
// file
if strings.Contains(key, "/") {
if res, _, ok := gossConfig.Files.AppendSysResourceIfExists(key, sys); ok == true {
resourcePrint(fileName, res)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function main
has 20 return statements (exceeds 4 allowed). Open
func main() {
startTime := time.Now()
app := cli.NewApp()
app.EnableBashCompletion = true
app.Version = version
Function matcherToGomegaMatcher
has 18 return statements (exceeds 4 allowed). Open
func matcherToGomegaMatcher(matcher interface{}) (types.GomegaMatcher, error) {
switch x := matcher.(type) {
case string, int, bool, float64:
return gomega.Equal(x), nil
case []interface{}:
Function AddResource
has 16 return statements (exceeds 4 allowed). Open
func AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config, sys *system.System) error {
// Need to figure out a good way to refactor this
switch resourceName {
case "Addr":
res, err := gossConfig.Addrs.AppendSysResource(key, sys, config)
Function ValidateContains
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func ValidateContains(res ResourceRead, property string, expectedValues []string, method func() (io.Reader, error), skip bool) TestResult {
id := res.ID()
title := res.GetTitle()
meta := res.GetMeta()
typ := reflect.TypeOf(res)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getGossConfig
has 9 return statements (exceeds 4 allowed). Open
func getGossConfig(vars string, varsInline string, specFile string) (cfg *GossConfig, err error) {
// handle stdin
var fh *os.File
var path, source string
var gossConfig GossConfig
Function skipResult
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func skipResult(typeS string, testType int, id string, title string, meta meta, property string, startTime time.Time) TestResult {
Method ResourceTypeMap.UnmarshalJSON
has 7 return statements (exceeds 4 allowed). Open
func (ret *ResourceTypeMap) UnmarshalJSON(data []byte) error {
// Curried json.Unmarshal
unmarshal := func(i interface{}) error {
if err := json.Unmarshal(data, i); err != nil {
return err
Avoid deeply nested control flow statements. Open
} else if _, err := os.Stat("/etc/debian_version"); err == nil {
return "debian"
}
Method MatchingMap.UnmarshalJSON
has 7 return statements (exceeds 4 allowed). Open
func (ret *MatchingMap) UnmarshalJSON(data []byte) error {
// Curried json.Unmarshal
unmarshal := func(i interface{}) error {
if err := json.Unmarshal(data, i); err != nil {
return err
Function DetectDistro
has 6 return statements (exceeds 4 allowed). Open
func DetectDistro() string {
if b, e := ioutil.ReadFile("/etc/lsb-release"); e == nil && bytes.Contains(b, []byte("Ubuntu")) {
return "ubuntu"
} else if isRedhat() {
return "redhat"
Function ValidateContains
has 6 return statements (exceeds 4 allowed). Open
func ValidateContains(res ResourceRead, property string, expectedValues []string, method func() (io.Reader, error), skip bool) TestResult {
id := res.ID()
title := res.GetTitle()
meta := res.GetMeta()
typ := reflect.TypeOf(res)
Function lookupUserGroups
has 6 return statements (exceeds 4 allowed). Open
func lookupUserGroups(userS user.User) ([]user.Group, error) {
// Get operating system-specific group reader-closer.
group, err := user.GetGroup()
if err != nil {
return []user.Group{user.Group{}}, err