dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

Function parseConfig has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
Open

func parseConfig(cfg map[string]string) (fluent.Config, error) {
    var config fluent.Config

    loc, err := parseAddress(cfg[addressKey])
    if err != nil {
Severity: Minor
Found in daemon/logger/fluentd/fluentd.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

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 Manager.Push has 81 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header, authConfig *registry.AuthConfig, outStream io.Writer) error {
        p, err := pm.config.Store.GetV2Plugin(name)
        if err != nil {
            return err
        }
    Severity: Major
    Found in plugin/backend_linux.go - About 2 hrs to fix

      Method CompoundMessage.Unmarshal has 81 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

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

        Method CompoundMessage_SimpleMessage.Unmarshal has 81 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          File image_builder.go has 510 lines of code (exceeds 500 allowed). Consider refactoring.
          Open

          package containerd
          
          import (
              "bytes"
              "context"
          Severity: Minor
          Found in daemon/containerd/image_builder.go - About 2 hrs to fix

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

            func (p PortBinding) HostAddr() (net.Addr, error) {
                switch p.Proto {
                case UDP:
                    return &net.UDPAddr{IP: p.HostIP, Port: int(p.HostPort)}, nil
                case TCP:
            Severity: Major
            Found in libnetwork/types/types.go and 1 other location - About 2 hrs to fix
            libnetwork/types/types.go on lines 95..106

            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 203.

            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 2 locations. Consider refactoring.
            Open

            func (p PortBinding) ContainerAddr() (net.Addr, error) {
                switch p.Proto {
                case UDP:
                    return &net.UDPAddr{IP: p.IP, Port: int(p.Port)}, nil
                case TCP:
            Severity: Major
            Found in libnetwork/types/types.go and 1 other location - About 2 hrs to fix
            libnetwork/types/types.go on lines 81..92

            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 203.

            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 Controller.NewSandbox has 80 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *Controller) NewSandbox(ctx context.Context, containerID string, options ...SandboxOption) (_ *Sandbox, retErr error) {
                if containerID == "" {
                    return nil, types.InvalidParameterErrorf("invalid container ID")
                }
            
            
            Severity: Major
            Found in libnetwork/controller.go - About 2 hrs to fix

              Method driver.configure has 80 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (d *driver) configure(option map[string]interface{}) error {
                  var (
                      config            configuration
                      err               error
                      natChain          *iptables.ChainInfo
              Severity: Major
              Found in libnetwork/drivers/bridge/bridge_linux.go - About 2 hrs to fix

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

                func (sr *swarmRouter) updateSecret(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                    var secret types.SecretSpec
                    if err := httputils.ReadJSON(r, &secret); err != nil {
                        return err
                    }
                Severity: Major
                Found in api/server/router/swarm/cluster_routes.go and 1 other location - About 2 hrs to fix
                api/server/router/swarm/cluster_routes.go on lines 545..559

                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 202.

                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 2 locations. Consider refactoring.
                Open

                func (sr *swarmRouter) updateConfig(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                    var config types.ConfigSpec
                    if err := httputils.ReadJSON(r, &config); err != nil {
                        return err
                    }
                Severity: Major
                Found in api/server/router/swarm/cluster_routes.go and 1 other location - About 2 hrs to fix
                api/server/router/swarm/cluster_routes.go on lines 473..487

                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 202.

                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 PortConfig.Unmarshal has 24 return statements (exceeds 4 allowed).
                Open

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

                  Method PeerRecord.Unmarshal has 24 return statements (exceeds 4 allowed).
                  Open

                  func (m *PeerRecord) Unmarshal(dAtA []byte) error {
                      l := len(dAtA)
                      iNdEx := 0
                      for iNdEx < l {
                          preIndex := iNdEx
                  Severity: Major
                  Found in libnetwork/drivers/windows/overlay/overlay.pb.go - About 2 hrs to fix

                    Worker has 21 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    type Worker struct {
                        Opt
                        SourceManager *source.Manager
                    }
                    Severity: Minor
                    Found in builder/builder-next/worker/worker.go - About 2 hrs to fix

                      Function verifyPlatformContainerResources has 24 return statements (exceeds 4 allowed).
                      Open

                      func verifyPlatformContainerResources(resources *containertypes.Resources, isHyperv bool) (warnings []string, err error) {
                          fixMemorySwappiness(resources)
                          if !isHyperv {
                              // The processor resource controls are mutually exclusive on
                              // Windows Server Containers, the order of precedence is
                      Severity: Major
                      Found in daemon/daemon_windows.go - About 2 hrs to fix

                        Method PortMapper.MapRange has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart, hostPortEnd int) (host net.Addr, retErr error) {
                            pm.lock.Lock()
                            defer pm.lock.Unlock()
                        
                            var (
                        Severity: Major
                        Found in libnetwork/portmapper/mapper.go - About 2 hrs to fix

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

                                  case 2:
                                      if wireType != 2 {
                                          return fmt.Errorf("proto: wrong wireType = %d for field EndpointMAC", wireType)
                                      }
                                      var stringLen uint64
                          Severity: Major
                          Found in libnetwork/drivers/windows/overlay/overlay.pb.go and 2 other locations - About 2 hrs to fix
                          libnetwork/drivers/windows/overlay/overlay.pb.go on lines 224..252
                          libnetwork/drivers/windows/overlay/overlay.pb.go on lines 282..310

                          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 199.

                          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

                                  case 1:
                                      if wireType != 2 {
                                          return fmt.Errorf("proto: wrong wireType = %d for field EndpointIP", wireType)
                                      }
                                      var stringLen uint64
                          Severity: Major
                          Found in libnetwork/drivers/windows/overlay/overlay.pb.go and 2 other locations - About 2 hrs to fix
                          libnetwork/drivers/windows/overlay/overlay.pb.go on lines 253..281
                          libnetwork/drivers/windows/overlay/overlay.pb.go on lines 282..310

                          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 199.

                          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

                          func (ep *endpoint) MarshalJSON() ([]byte, error) {
                              epMap := make(map[string]interface{})
                              epMap["id"] = ep.id
                              epMap["nid"] = ep.nid
                              epMap["SrcName"] = ep.srcName
                          Severity: Major
                          Found in libnetwork/drivers/macvlan/macvlan_store.go and 1 other location - About 2 hrs to fix
                          libnetwork/drivers/ipvlan/ipvlan_store.go on lines 245..260

                          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 199.

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language