docker/docker

View on GitHub
daemon/list.go

Summary

Maintainability
F
3 days
Test Coverage

Function includeContainerInList has a Cognitive Complexity of 84 (exceeds 20 allowed). Consider refactoring.
Open

func includeContainerInList(container *container.Snapshot, filter *listContext) iterationAction {
    // Do not include container if it's in the list before the filter container.
    // Set the filter container to nil to include the rest of containers after this one.
    if filter.beforeFilter != nil {
        if container.ID == filter.beforeFilter.ID {
Severity: Minor
Found in daemon/list.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 includeContainerInList has 137 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func includeContainerInList(container *container.Snapshot, filter *listContext) iterationAction {
    // Do not include container if it's in the list before the filter container.
    // Set the filter container to nil to include the rest of containers after this one.
    if filter.beforeFilter != nil {
        if container.ID == filter.beforeFilter.ID {
Severity: Major
Found in daemon/list.go - About 4 hrs to fix

    Method Daemon.foldFilter has 95 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) {
        psFilters := config.Filters
    
        var filtExited []int
    
    
    Severity: Major
    Found in daemon/list.go - About 2 hrs to fix

      Function includeContainerInList has 25 return statements (exceeds 4 allowed).
      Open

      func includeContainerInList(container *container.Snapshot, filter *listContext) iterationAction {
          // Do not include container if it's in the list before the filter container.
          // Set the filter container to nil to include the rest of containers after this one.
          if filter.beforeFilter != nil {
              if container.ID == filter.beforeFilter.ID {
      Severity: Major
      Found in daemon/list.go - About 2 hrs to fix

        Method Daemon.foldFilter has 21 return statements (exceeds 4 allowed).
        Open

        func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) {
            psFilters := config.Filters
        
            var filtExited []int
        
        
        Severity: Major
        Found in daemon/list.go - About 1 hr to fix

          Method Daemon.filterByNameIDMatches has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
          Open

          func (daemon *Daemon) filterByNameIDMatches(view *container.View, filter *listContext) ([]container.Snapshot, error) {
              idSearch := false
              names := filter.filters.Get("name")
              ids := filter.filters.Get("id")
              if len(names)+len(ids) == 0 {
          Severity: Minor
          Found in daemon/list.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 Daemon.foldFilter has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
          Open

          func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) {
              psFilters := config.Filters
          
              var filtExited []int
          
          
          Severity: Minor
          Found in daemon/list.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

          Method Daemon.Containers has 6 return statements (exceeds 4 allowed).
          Open

          func (daemon *Daemon) Containers(ctx context.Context, config *containertypes.ListOptions) ([]*types.Container, error) {
              if err := config.Filters.Validate(acceptedPsFilterTags); err != nil {
                  return nil, err
              }
          
          
          Severity: Major
          Found in daemon/list.go - About 40 mins to fix

            There are no issues that match your filters.

            Category
            Status