SimonBaeumer/goss

View on GitHub

Showing 58 of 157 total issues

File resource_list.go has 1234 lines of code (exceeds 500 allowed). Consider refactoring.
Open

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

    Function createAddCommand has 134 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func createAddCommand(app *cli.App) cli.Command {
        return cli.Command{
            Name:    "add",
            Aliases: []string{"a"},
            Usage:   "add a resource to the test suite",
    Severity: Major
    Found in cmd/goss/goss.go - About 4 hrs to fix

      Function ValidateContains has 126 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 {
          format.TruncatedDiff = false
          id := res.ID()
          title := res.GetTitle()
          meta := res.GetMeta()
      Severity: Major
      Found in resource/validate.go - About 4 hrs to fix

        Method Add.AddResource has 110 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (a *Add) AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config) error {
            // Need to figure out a good way to refactor this
            switch resourceName {
            case "addr":
                res, err := gossConfig.Addrs.AppendSysResource(key, a.Sys, config)
        Severity: Major
        Found in add.go - About 3 hrs to fix

          Function matcherToGomegaMatcher has 99 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 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 80 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func ValidateValue(res ResourceRead, property string, expectedValue interface{}, actual interface{}, skip bool) TestResult {
                format.TruncatedDiff = false
                id := res.ID()
                title := res.GetTitle()
                meta := res.GetMeta()
            Severity: Major
            Found in resource/validate.go - About 2 hrs to fix

              Method Add.AddResource has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
              Open

              func (a *Add) AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config) error {
                  // Need to figure out a good way to refactor this
                  switch resourceName {
                  case "addr":
                      res, err := gossConfig.Addrs.AppendSysResource(key, a.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 createValidateCommand has 70 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func createValidateCommand(app *cli.App) cli.Command {
                  startTime := time.Now()
              
                  return cli.Command{
                      Name:    "validate",
              Severity: Minor
              Found in cmd/goss/goss.go - About 1 hr to fix

                Method Add.AutoAddResource has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
                Open

                func (a *Add) AutoAddResource(fileName string, gossConfig GossConfig, key string) error {
                    // file
                    if strings.Contains(key, "/") {
                        if res, _, ok := gossConfig.Files.AppendSysResourceIfExists(key, a.Sys); ok == true {
                            a.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 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 createApp has 65 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func createApp() *cli.App {
                      app := cli.NewApp()
                      app.EnableBashCompletion = true
                      app.Version = version
                      app.Name = "goss"
                  Severity: Minor
                  Found in cmd/goss/goss.go - About 1 hr to fix

                    Function createServeCommand has 63 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func createServeCommand() cli.Command {
                        return cli.Command{
                            Name:    "serve",
                            Aliases: []string{"s"},
                            Usage:   "Serve a health endpoint",
                    Severity: Minor
                    Found in cmd/goss/goss.go - About 1 hr to fix

                      Function validateHeader has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func validateHeader(res ResourceRead, property string, expectedHeaders map[string][]string, actualHeaders system.Header, skip bool) TestResult {
                          id := res.ID()
                          title := res.GetTitle()
                          meta := res.GetMeta()
                          typ := reflect.TypeOf(res)
                      Severity: Minor
                      Found in resource/http.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 {
                            format.TruncatedDiff = false
                            id := res.ID()
                            title := res.GetTitle()
                            meta := res.GetMeta()
                        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 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 ServiceMap.UnmarshalJSON has 7 return statements (exceeds 4 allowed).
                          Open

                          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
                          Severity: Major
                          Found in resource/resource_list.go - About 45 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

                              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

                                Method CommandMap.UnmarshalJSON has 7 return statements (exceeds 4 allowed).
                                Open

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