dotcloud/docker

View on GitHub
daemon/logger/copier.go

Summary

Maintainability
D
2 days
Test Coverage

Method Copier.copySrc has a Cognitive Complexity of 75 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Copier) copySrc(name string, src io.Reader) {
    defer c.copyJobs.Done()

    bufSize := defaultBufSize
    if sizedLogger, ok := c.dst.(SizedLogger); ok {
Severity: Minor
Found in daemon/logger/copier.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

Method Copier.copySrc has 101 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *Copier) copySrc(name string, src io.Reader) {
    defer c.copyJobs.Done()

    bufSize := defaultBufSize
    if sizedLogger, ok := c.dst.(SizedLogger); ok {
Severity: Major
Found in daemon/logger/copier.go - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                        if logErr := c.dst.Log(msg); logErr != nil {
                            logDriverError(c.dst.Name(), string(msg.Line), logErr)
                        }
    Severity: Major
    Found in daemon/logger/copier.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if hasMorePartial {
                              msg.PLogMetaData = &types.PartialLogMetaData{ID: partialid, Ordinal: ordinal, Last: true}
      
                              // reset
                              partialid = ""
      Severity: Major
      Found in daemon/logger/copier.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if firstPartial {
                                msg.Timestamp = time.Now().UTC()
                                partialTS = msg.Timestamp
                                partialid = stringid.GenerateRandomID()
                                ordinal = 1
        Severity: Major
        Found in daemon/logger/copier.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if logErr := c.dst.Log(msg); logErr != nil {
                                  logDriverError(c.dst.Name(), string(msg.Line), logErr)
                              }
          Severity: Major
          Found in daemon/logger/copier.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if err != io.EOF {
                                    logReadsFailedCount.Inc(1)
                                    log.G(context.TODO()).Errorf("Error scanning log stream: %s", err)
                                    return
                                }
            Severity: Major
            Found in daemon/logger/copier.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if msg.PLogMetaData == nil {
                                      msg.Timestamp = time.Now().UTC()
                                  } else {
                                      msg.Timestamp = partialTS
                                  }
              Severity: Major
              Found in daemon/logger/copier.go - About 45 mins to fix

                Method Copier.copySrc has 5 return statements (exceeds 4 allowed).
                Open

                func (c *Copier) copySrc(name string, src io.Reader) {
                    defer c.copyJobs.Done()
                
                    bufSize := defaultBufSize
                    if sizedLogger, ok := c.dst.(SizedLogger); ok {
                Severity: Major
                Found in daemon/logger/copier.go - About 35 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status