dotcloud/docker

View on GitHub
daemon/logger/journald/read.go

Summary

Maintainability
C
1 day
Test Coverage

Method reader.drainJournal has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
Open

func (r *reader) drainJournal(ctx context.Context) (bool, error) {
    for i := 0; ; i++ {
        // Read the entry's timestamp.
        timestamp, err := r.j.Realtime()
        if err != nil {
Severity: Minor
Found in daemon/logger/journald/read.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 reader.readLogs has 55 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (r *reader) readLogs(ctx context.Context) {
    defer close(r.logWatcher.Msg)

    // Make sure the ready channel is closed in the event of an early
    // return.
Severity: Minor
Found in daemon/logger/journald/read.go - About 1 hr to fix

    Function waitUntilFlushedImpl has 55 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func waitUntilFlushedImpl(s *journald) error {
        if s.readSyncTimeout == 0 {
            return nil
        }
    
    
    Severity: Minor
    Found in daemon/logger/journald/read.go - About 1 hr to fix

      Function waitUntilFlushedImpl has 10 return statements (exceeds 4 allowed).
      Open

      func waitUntilFlushedImpl(s *journald) error {
          if s.readSyncTimeout == 0 {
              return nil
          }
      
      
      Severity: Major
      Found in daemon/logger/journald/read.go - About 1 hr to fix

        Method reader.initialSeekTail has 8 return statements (exceeds 4 allowed).
        Open

        func (r *reader) initialSeekTail() (bool, error) {
            var err error
            if r.config.Until.IsZero() {
                err = r.j.SeekTail()
            } else {
        Severity: Major
        Found in daemon/logger/journald/read.go - About 50 mins to fix

          Method reader.readLogs has 8 return statements (exceeds 4 allowed).
          Open

          func (r *reader) readLogs(ctx context.Context) {
              defer close(r.logWatcher.Msg)
          
              // Make sure the ready channel is closed in the event of an early
              // return.
          Severity: Major
          Found in daemon/logger/journald/read.go - About 50 mins to fix

            Method reader.wait has 7 return statements (exceeds 4 allowed).
            Open

            func (r *reader) wait(ctx context.Context) (bool, error) {
                deadline := r.drainDeadline
                if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
                    deadline = d
                }
            Severity: Major
            Found in daemon/logger/journald/read.go - About 45 mins to fix

              Method reader.drainJournal has 7 return statements (exceeds 4 allowed).
              Open

              func (r *reader) drainJournal(ctx context.Context) (bool, error) {
                  for i := 0; ; i++ {
                      // Read the entry's timestamp.
                      timestamp, err := r.j.Realtime()
                      if err != nil {
              Severity: Major
              Found in daemon/logger/journald/read.go - About 45 mins to fix

                Method reader.readJournal has 6 return statements (exceeds 4 allowed).
                Open

                func (r *reader) readJournal(ctx context.Context) error {
                    caughtUp := r.s.ordinal.Load()
                    if more, err := r.drainJournal(ctx); err != nil || !more {
                        return err
                    }
                Severity: Major
                Found in daemon/logger/journald/read.go - About 40 mins to fix

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

                  func (r *reader) wait(ctx context.Context) (bool, error) {
                      deadline := r.drainDeadline
                      if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
                          deadline = d
                      }
                  Severity: Minor
                  Found in daemon/logger/journald/read.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

                  Function waitUntilFlushedImpl has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func waitUntilFlushedImpl(s *journald) error {
                      if s.readSyncTimeout == 0 {
                          return nil
                      }
                  
                  
                  Severity: Minor
                  Found in daemon/logger/journald/read.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

                  Method reader.readLogs has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (r *reader) readLogs(ctx context.Context) {
                      defer close(r.logWatcher.Msg)
                  
                      // Make sure the ready channel is closed in the event of an early
                      // return.
                  Severity: Minor
                  Found in daemon/logger/journald/read.go - About 25 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

                  There are no issues that match your filters.

                  Category
                  Status