nirnanaaa/asparagus

View on GitHub

Showing 21 of 48 total issues

Method Config.applyEnvOverrides has a Cognitive Complexity of 72 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Config) applyEnvOverrides(prefix string, spec reflect.Value) error {
    // If we have a pointer, dereference it
    s := spec
    if spec.Kind() == reflect.Ptr {
        s = spec.Elem()
Severity: Minor
Found in run/config.go - About 1 day 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 metricsData has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring.
Open

func metricsData(registry metrics.Registry, cfg *config.Config) []*cloudwatch.MetricDatum {

    data := []*cloudwatch.MetricDatum{}
    timestamp := aws.Time(time.Now())

Severity: Minor
Found in metric/adapters/cloudwatch/cloudwatch.go - About 5 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 metricsData has 103 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func metricsData(registry metrics.Registry, cfg *config.Config) []*cloudwatch.MetricDatum {

    data := []*cloudwatch.MetricDatum{}
    timestamp := aws.Time(time.Now())

Severity: Major
Found in metric/adapters/cloudwatch/cloudwatch.go - About 3 hrs to fix

    Method Config.applyEnvOverrides has 86 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *Config) applyEnvOverrides(prefix string, spec reflect.Value) error {
        // If we have a pointer, dereference it
        s := spec
        if spec.Kind() == reflect.Ptr {
            s = spec.Elem()
    Severity: Major
    Found in run/config.go - About 2 hrs to fix

      Function MapToStruct has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
      Open

      func MapToStruct(t interface{}, values map[string]interface{}) error {
          ps := reflect.ValueOf(t)
          // struct
          s := ps.Elem()
          if s.Kind() != reflect.Struct {
      Severity: Minor
      Found in reflection/map_to_struct.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

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

      func (w *Worker) Start() {
          go func() {
              for {
                  // Add ourselves into the worker queue.
                  w.WorkerQueue <- w.Work
      Severity: Minor
      Found in scheduler/worker.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

      Method Config.applyEnvOverrides has 11 return statements (exceeds 4 allowed).
      Open

      func (c *Config) applyEnvOverrides(prefix string, spec reflect.Value) error {
          // If we have a pointer, dereference it
          s := spec
          if spec.Kind() == reflect.Ptr {
              s = spec.Elem()
      Severity: Major
      Found in run/config.go - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

            } else if !c.HTTPExecutor.Enabled {
                t.Fatalf("unexpected http executor enabled %v", c.HTTPExecutor.Enabled)
            } else if !c.CrontabSource.Enabled {
                t.Fatalf("unexpected crontab source enabled %v", c.CrontabSource.Enabled)
            }
        Severity: Major
        Found in scheduler/config_test.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

              } else if len(c.RegistryURL) != 1 {
                  t.Fatalf("unexpected registry urls: %v", c.RegistryURL)
              } else if c.CACert != "/etc/ssl/certs/ca.crt" {
                  t.Fatalf("unexpected ssl cert root: %v", c.CACert)
              } else if c.SourceFolder != "/cron/jobs" {
          Severity: Major
          Found in scheduler/provider/etcd/config_test.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if err != nil {
                                    return fmt.Errorf("failed to apply %v to %v using type %v and value '%v'", key, fieldKey, f.Type().String(), value)
                                }
            Severity: Major
            Found in run/config.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                  } else if c.JWTSubject != "0" {
                      t.Fatalf("unexpected jwt subject: %v", c.JWTSubject)
                  } else if c.Issuer != "issuer" {
                      t.Fatalf("unexpected issuer: %v", c.Issuer)
                  } else if c.JWTSecret != "" {
              Severity: Major
              Found in scheduler/provider/http/config_test.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if err := c.applyEnvOverrides(key, f.Index(i)); err != nil {
                                        return err
                                    }
                Severity: Major
                Found in run/config.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if err := c.applyEnvOverrides(fmt.Sprintf("%s_%d", key, i), f.Index(i)); err != nil {
                                          return err
                                      }
                  Severity: Major
                  Found in run/config.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if err != nil {
                                            return fmt.Errorf("failed to apply %v to %v using type %v and value '%v'", key, fieldKey, f.Type().String(), value)
                                        }
                    Severity: Major
                    Found in run/config.go - About 45 mins to fix

                      Method Command.Run has 6 return statements (exceeds 4 allowed).
                      Open

                      func (cmd *Command) Run(args ...string) error {
                      
                          options, err := cmd.ParseFlags(args...)
                          if err != nil {
                              return err
                      Severity: Major
                      Found in run/main.go - About 40 mins to fix

                        Method ExecutionProvider.Execute has 6 return statements (exceeds 4 allowed).
                        Open

                        func (p *ExecutionProvider) Execute(t interface{}, r *provider.Response) error {
                            if !p.Config.Enabled {
                                return fmt.Errorf("Local Executor is disabled. Please enable it in the configuration")
                            }
                            var task ExecutionData
                        Severity: Major
                        Found in scheduler/provider/local/execution_provider.go - About 40 mins to fix

                          Method Executor.Request has 5 return statements (exceeds 4 allowed).
                          Open

                          func (e *Executor) Request(url, method string, resq *provider.Response) (response *http.Response, erro error) {
                              e.RequestTiming.Time(func() {
                                  req, err := http.NewRequest(strings.ToUpper(method), url, nil)
                                  if err != nil {
                                      e.ErrorCounter.Inc(1)
                          Severity: Major
                          Found in scheduler/provider/http/executor.go - About 35 mins to fix

                            Method Options.GetConfigPath has 5 return statements (exceeds 4 allowed).
                            Open

                            func (opt *Options) GetConfigPath() string {
                                if opt.ConfigPath != "" {
                                    if opt.ConfigPath == os.DevNull {
                                        return ""
                                    }
                            Severity: Major
                            Found in run/main.go - About 35 mins to fix

                              Method PrintConfigCommand.Run has 5 return statements (exceeds 4 allowed).
                              Open

                              func (cmd *PrintConfigCommand) Run(args ...string) error {
                                  // Parse command flags.
                                  fs := flag.NewFlagSet("", flag.ContinueOnError)
                                  configPath := fs.String("config", "", "")
                                  fs.Usage = func() { fmt.Fprintln(cmd.Stderr, printConfigUsage) }
                              Severity: Major
                              Found in run/config_command.go - About 35 mins to fix

                                Method Reporter.LogResult has 5 return statements (exceeds 4 allowed).
                                Open

                                func (r *Reporter) LogResult(evt *adapters.LogEvent) error {
                                    var reader io.Reader
                                    buf := new(bytes.Buffer)
                                    if err := r.parseTemplate(evt, buf); err != nil {
                                        return err
                                Severity: Major
                                Found in metric/adapters/slack/reporter.go - About 35 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language