pedroMMM/goss

View on GitHub

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
Severity: Major
Found in cmd/goss/goss.go - About 1 day to fix

    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)
    Severity: Major
    Found in resource/validate.go - About 4 hrs to fix

      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{}:
      Severity: Major
      Found in resource/gomega.go - About 3 hrs to fix

        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)
        Severity: Major
        Found in add.go - About 2 hrs to fix

          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{}:
          Severity: Minor
          Found in resource/gomega.go - About 2 hrs to fix

          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)
          Severity: Major
          Found in resource/validate.go - About 2 hrs to fix

            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)
            Severity: Minor
            Found in add.go - About 2 hrs to fix

            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)
            Severity: Minor
            Found in add.go - About 1 hr to fix

            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
            Severity: Major
            Found in cmd/goss/goss.go - About 1 hr to fix

              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{}:
              Severity: Major
              Found in resource/gomega.go - About 1 hr to fix

                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)
                Severity: Major
                Found in add.go - About 1 hr to fix

                  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)
                  Severity: Minor
                  Found in resource/validate.go - About 1 hr to fix

                  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
                  Severity: Major
                  Found in validate.go - About 55 mins to fix

                    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 {
                    Severity: Major
                    Found in resource/validate.go - About 50 mins to fix

                      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
                      Severity: Major
                      Found in resource/resource_list_genny.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                            } else if _, err := os.Stat("/etc/debian_version"); err == nil {
                                return "debian"
                            }
                        Severity: Major
                        Found in system/system.go - About 45 mins to fix

                          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
                          Severity: Major
                          Found in resource/matching.go - About 45 mins to fix

                            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"
                            Severity: Major
                            Found in system/system.go - About 40 mins to fix

                              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)
                              Severity: Major
                              Found in resource/validate.go - About 40 mins to fix

                                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
                                Severity: Major
                                Found in system/user.go - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language