simonmittag/p0d

View on GitHub

Showing 20 of 24 total issues

File p0d.go has 884 lines of code (exceeds 500 allowed). Consider refactoring.
Confirmed

package p0d

import (
    "bytes"
    "context"
Severity: Major
Found in p0d.go - About 1 day to fix

    Method P0d.initLog has 144 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (p *P0d) initLog() {
        PrintLogo()
        PrintVersion()
        fmt.Printf("\n")
        if p.Config.File != "" {
    Severity: Major
    Found in p0d.go - About 4 hrs to fix

      Method Config.validate has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
      Confirmed

      func (cfg *Config) validate() *Config {
          //we always want this.
          cfg.Req.Method = strings.ToUpper(cfg.Req.Method)
          if cfg.Req.Method == "" {
              cfg.Req.Method = "GET"
      Severity: Minor
      Found in config.go - About 4 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

      P0d has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type P0d struct {
          ID          string
          Time        Time
          Config      Config
          OS          OS
      Severity: Minor
      Found in p0d.go - About 2 hrs to fix

        Method P0d.doLogLive has 88 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (p *P0d) doLogLive() {
            logLiveLock.Lock()
            elpsd := time.Now()
        
            lw := p.liveWriters
        Severity: Major
        Found in p0d.go - About 2 hrs to fix

          Method ProgressBar.render has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
          Confirmed

          func (p *ProgressBar) render(now time.Time, pod *P0d) string {
          
              if pod.Time.Stop.IsZero() {
                  fsi := p.chunkPropIndexFor(now, pod)
          
          
          Severity: Minor
          Found in progressbar.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.validate has 78 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (cfg *Config) validate() *Config {
              //we always want this.
              cfg.Req.Method = strings.ToUpper(cfg.Req.Method)
              if cfg.Req.Method == "" {
                  cfg.Req.Method = "GET"
          Severity: Major
          Found in config.go - About 2 hrs to fix

            Method P0d.Race has 77 lines of code (exceeds 50 allowed). Consider refactoring.
            Confirmed

            func (p *P0d) Race() {
                osStatsDone := make(chan struct{}, 2)
                p.initOSStats(osStatsDone)
                p.detectRemoteConnSettings()
                p.initLog()
            Severity: Major
            Found in p0d.go - About 2 hrs to fix

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

              func (p *P0d) initLog() {
                  PrintLogo()
                  PrintVersion()
                  fmt.Printf("\n")
                  if p.Config.File != "" {
              Severity: Minor
              Found in p0d.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

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

              func (p *P0d) scaffoldHttpReq() *http.Request {
                  var body io.Reader
              
                  //multipartwriter adds a boundary
                  var mpContentType string
              Severity: Minor
              Found in p0d.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

              Method P0d.doReqAtmpts has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
              Confirmed

              func (p *P0d) doReqAtmpts(i int, ras chan<- ReqAtmpt, done <-chan struct{}) {
              ReqAtmpt:
                  for {
                      select {
                      case <-done:
              Severity: Minor
              Found in p0d.go - About 45 mins 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 NewP0dWithValues has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func NewP0dWithValues(c int, d int, u string, h string, o string, s bool) *P0d {
              Severity: Minor
              Found in p0d.go - About 45 mins to fix

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

                func (cfg *Config) validateReqBody() {
                    if len(cfg.Req.Body) > 0 {
                        if len(cfg.Req.FormData) > 0 {
                            cfg.panic("when specifying request body, cannot have form data")
                        }
                Severity: Minor
                Found in config.go - About 45 mins 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

                Avoid deeply nested control flow statements.
                Open

                                    if p.chunkProps[i].hasErrors {
                                        f.WriteString(Red(RAMP).String())
                                    } else {
                                        f.WriteString(Cyan(RAMP).String())
                                    }
                Severity: Major
                Found in progressbar.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if p.chunkProps[i].hasErrors {
                                          f.WriteString(Red(FULL).String())
                                      } else {
                                          f.WriteString(Cyan(FULL).String())
                                      }
                  Severity: Major
                  Found in progressbar.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                        } else if p.isTimerPhase(Drained) {
                            connMsg += drained
                        }
                    Severity: Major
                    Found in p0d.go - About 45 mins to fix

                      Method P0d.Race has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (p *P0d) Race() {
                          osStatsDone := make(chan struct{}, 2)
                          p.initOSStats(osStatsDone)
                          p.detectRemoteConnSettings()
                          p.initLog()
                      Severity: Minor
                      Found in p0d.go - About 45 mins 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

                      Avoid deeply nested control flow statements.
                      Open

                                  } else if rr.TLS.Version == tls.VersionTLS11 {
                                      p.ReqStats.Sample.TLSVersion = "TLS1.1"
                                  } else if rr.TLS.Version == tls.VersionTLS12 {
                                      p.ReqStats.Sample.TLSVersion = "TLS1.2"
                                  } else if rr.TLS.Version == tls.VersionTLS13 {
                      Severity: Major
                      Found in p0d.go - About 45 mins to fix

                        Function NewP0d has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func NewP0d(cfg Config, ulimit int64, outputFile string, durationSecs int, interrupt chan os.Signal) *P0d {
                        Severity: Minor
                        Found in p0d.go - About 35 mins to fix

                          Method P0d.initReqAtmpts has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (p *P0d) initReqAtmpts(done chan struct{}, ras chan ReqAtmpt) {
                          
                              //don't block because execution continues on to live updates
                              go func() {
                                  bd := false
                          Severity: Minor
                          Found in p0d.go - About 35 mins 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

                          Severity
                          Category
                          Status
                          Source
                          Language