docker/docker

View on GitHub

Showing 1,853 of 1,853 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

package ivmanager

import (
    "github.com/docker/docker/libnetwork/driverapi"
    "github.com/docker/docker/libnetwork/scope"
Severity: Major
Found in libnetwork/drivers/ipvlan/ivmanager/ivmanager.go and 2 other locations - About 1 day to fix
libnetwork/drivers/bridge/brmanager/brmanager.go on lines 1..78
libnetwork/drivers/macvlan/mvmanager/mvmanager.go on lines 1..78

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 863.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

package brmanager

import (
    "github.com/docker/docker/libnetwork/driverapi"
    "github.com/docker/docker/libnetwork/scope"
Severity: Major
Found in libnetwork/drivers/bridge/brmanager/brmanager.go and 2 other locations - About 1 day to fix
libnetwork/drivers/ipvlan/ivmanager/ivmanager.go on lines 1..78
libnetwork/drivers/macvlan/mvmanager/mvmanager.go on lines 1..78

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 863.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

package mvmanager

import (
    "github.com/docker/docker/libnetwork/driverapi"
    "github.com/docker/docker/libnetwork/scope"
Severity: Major
Found in libnetwork/drivers/macvlan/mvmanager/mvmanager.go and 2 other locations - About 1 day to fix
libnetwork/drivers/bridge/brmanager/brmanager.go on lines 1..78
libnetwork/drivers/ipvlan/ivmanager/ivmanager.go on lines 1..78

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 863.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method containerRouter.postContainersCreate has a Cognitive Complexity of 97 (exceeds 20 allowed). Consider refactoring.
Open

func (s *containerRouter) postContainersCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
    if err := httputils.ParseForm(r); err != nil {
        return err
    }
    if err := httputils.CheckForJSON(r); err != nil {
Severity: Minor
Found in api/server/router/container/container_routes.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

File endpoint.go has 938 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.19

package libnetwork

Severity: Major
Found in libnetwork/endpoint.go - About 1 day to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    //go:build linux
    
    package macvlan
    
    import (
    Severity: Major
    Found in libnetwork/drivers/macvlan/macvlan_state.go and 1 other location - About 1 day to fix
    libnetwork/drivers/ipvlan/ipvlan_state.go on lines 1..104

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 812.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    //go:build linux
    
    package ipvlan
    
    import (
    Severity: Major
    Found in libnetwork/drivers/ipvlan/ipvlan_state.go and 1 other location - About 1 day to fix
    libnetwork/drivers/macvlan/macvlan_state.go on lines 1..102

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 812.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method NodeEvent.Unmarshal has a Cognitive Complexity of 92 (exceeds 20 allowed). Consider refactoring.
    Open

    func (m *NodeEvent) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Minor
    Found in libnetwork/networkdb/networkdb.pb.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 PartialLogEntryMetadata.Unmarshal has a Cognitive Complexity of 92 (exceeds 20 allowed). Consider refactoring.
    Open

    func (m *PartialLogEntryMetadata) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Minor
    Found in api/types/plugins/logdriver/entry.pb.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 EndpointRecord.Unmarshal has 325 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (m *EndpointRecord) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Major
    Found in libnetwork/agent.pb.go - About 1 day to fix

      File local_windows.go has 911 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package local // import "github.com/docker/docker/libcontainerd/local"
      
      // This package contains the legacy in-proc calls in HCS using the v1 schema
      // for Windows runtime purposes.
      
      
      Severity: Major
      Found in libcontainerd/local/local_windows.go - About 1 day to fix

        File oci_linux.go has 905 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package daemon // import "github.com/docker/docker/daemon"
        
        import (
            "context"
            "fmt"
        Severity: Major
        Found in daemon/oci_linux.go - About 1 day to fix

          File container_operations.go has 902 lines of code (exceeds 500 allowed). Consider refactoring.
          Open

          // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
          //go:build go1.19
          
          package daemon // import "github.com/docker/docker/daemon"
          
          
          Severity: Major
          Found in daemon/container_operations.go - About 1 day to fix

            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

            File pull_v2.go has 868 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package distribution // import "github.com/docker/docker/distribution"
            
            import (
                "context"
                "encoding/json"
            Severity: Major
            Found in distribution/pull_v2.go - About 1 day to fix

              File network.go has 863 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              package daemon // import "github.com/docker/docker/daemon"
              
              import (
                  "context"
                  "errors"
              Severity: Major
              Found in daemon/network.go - About 1 day to fix

                Method LayerDownloadManager.makeDownloadFunc has a Cognitive Complexity of 82 (exceeds 20 allowed). Consider refactoring.
                Open

                func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, parentLayer layer.ChainID, parentDownload *downloadTransfer) doFunc {
                    return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer {
                        d := &downloadTransfer{
                            transfer:   newTransfer(),
                            layerStore: ldm.layerStore,
                Severity: Minor
                Found in distribution/xfer/download.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 setupSeccomp has a Cognitive Complexity of 82 (exceeds 20 allowed). Consider refactoring.
                Open

                func setupSeccomp(config *Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
                    if config == nil {
                        return nil, nil
                    }
                
                
                Severity: Minor
                Found in profiles/seccomp/seccomp_linux.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 Controller.NewNetwork has a Cognitive Complexity of 79 (exceeds 20 allowed). Consider refactoring.
                Open

                func (c *Controller) NewNetwork(networkType, name string, id string, options ...NetworkOption) (_ *Network, retErr error) {
                    if id != "" {
                        c.networkLocker.Lock(id)
                        defer c.networkLocker.Unlock(id) //nolint:errcheck
                
                
                Severity: Minor
                Found in libnetwork/controller.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 skipOverlay has a Cognitive Complexity of 78 (exceeds 20 allowed). Consider refactoring.
                Open

                func skipOverlay(dAtA []byte) (n int, err error) {
                    l := len(dAtA)
                    iNdEx := 0
                    for iNdEx < l {
                        var wire uint64
                Severity: Minor
                Found in libnetwork/drivers/windows/overlay/overlay.pb.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

                Severity
                Category
                Status
                Source
                Language