dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

Function setupIPChains has 61 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func setupIPChains(config configuration, version iptables.IPVersion) (natChain *iptables.ChainInfo, filterChain *iptables.ChainInfo, isolationChain1 *iptables.ChainInfo, isolationChain2 *iptables.ChainInfo, retErr error) {
    // Sanity check.
    if version == iptables.IPv4 && !config.EnableIPTables {
        return nil, nil, nil, nil, errors.New("cannot create new chains, iptables is disabled")
    }
Severity: Minor
Found in libnetwork/drivers/bridge/setup_ip_tables_linux.go - About 1 hr to fix

    Method Service.lookupV2Endpoints has 61 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, err error) {
        ana := s.config.allowNondistributableArtifacts(hostname)
    
        if hostname == DefaultNamespace || hostname == IndexHostname {
            for _, mirror := range s.config.Mirrors {
    Severity: Minor
    Found in registry/service_v2.go - About 1 hr to fix

      Method Daemon.allocateNetwork has 61 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (daemon *Daemon) allocateNetwork(ctx context.Context, cfg *config.Config, ctr *container.Container) (retErr error) {
          if daemon.netController == nil {
              return nil
          }
      
      
      Severity: Minor
      Found in daemon/container_operations.go - About 1 hr to fix

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

        func (c *Controller) addContainerNameResolution(nID, eID, containerName string, taskAliases []string, ip net.IP, method string) error {
            n, err := c.NetworkByID(nID)
            if err != nil {
                return err
            }
        Severity: Major
        Found in libnetwork/service_common.go and 1 other location - About 1 hr to fix
        libnetwork/service_common.go on lines 121..137

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

        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 (c *Controller) delContainerNameResolution(nID, eID, containerName string, taskAliases []string, ip net.IP, method string) error {
            n, err := c.NetworkByID(nID)
            if err != nil {
                return err
            }
        Severity: Major
        Found in libnetwork/service_common.go and 1 other location - About 1 hr to fix
        libnetwork/service_common.go on lines 57..73

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

        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 pushDescriptor.layerAlreadyExists has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
        Open

        func (pd *pushDescriptor) layerAlreadyExists(
            ctx context.Context,
            progressOutput progress.Output,
            diffID layer.DiffID,
            checkOtherRepositories bool,
        Severity: Minor
        Found in distribution/push_v2.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 layerDescriptor.Download has 15 return statements (exceeds 4 allowed).
        Open

        func (ld *layerDescriptor) Download(ctx context.Context, progressOutput progress.Output) (io.ReadCloser, int64, error) {
            log.G(ctx).Debugf("pulling blob %q", ld.digest)
        
            var (
                err    error
        Severity: Major
        Found in distribution/pull_v2.go - About 1 hr to fix

          Method tarexporter.legacyLoadImage has 15 return statements (exceeds 4 allowed).
          Open

          func (l *tarexporter) legacyLoadImage(oldID, sourceDir string, loadedMap map[string]image.ID, progressOutput progress.Output) error {
              if _, loaded := loadedMap[oldID]; loaded {
                  return nil
              }
              configPath, err := safePath(sourceDir, filepath.Join(oldID, legacyConfigFileName))
          Severity: Major
          Found in image/tarexport/load.go - About 1 hr to fix

            Method CompoundMessage_SimpleMessage.Unmarshal has 15 return statements (exceeds 4 allowed).
            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 1 hr to fix

              Method driver.Join has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
              Open

              func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
                  ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.overlay.Join", trace.WithAttributes(
                      attribute.String("nid", nid),
                      attribute.String("eid", eid),
                      attribute.String("sboxKey", sboxKey)))
              Severity: Minor
              Found in libnetwork/drivers/overlay/joinleave.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

              Function skipOverlay has 15 return statements (exceeds 4 allowed).
              Open

              func skipOverlay(dAtA []byte) (n int, err error) {
                  l := len(dAtA)
                  iNdEx := 0
                  for iNdEx < l {
                      var wire uint64
              Severity: Major
              Found in libnetwork/drivers/windows/overlay/overlay.pb.go - About 1 hr to fix

                Method imageExporterInstance.Export has 15 return statements (exceeds 4 allowed).
                Open

                func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source, inlineCache exptypes.InlineCache, sessionID string) (map[string]string, exporter.DescriptorReference, error) {
                    if len(inp.Refs) > 1 {
                        return nil, nil, fmt.Errorf("exporting multiple references to image store is currently unsupported")
                    }
                
                
                Severity: Major
                Found in builder/builder-next/exporter/mobyexporter/export.go - About 1 hr to fix

                  Method snapshotter.EnsureLayer has 15 return statements (exceeds 4 allowed).
                  Open

                  func (s *snapshotter) EnsureLayer(ctx context.Context, key string) ([]layer.DiffID, error) {
                      s.layerCreateLocker.Lock(key)
                      defer s.layerCreateLocker.Unlock(key)
                  
                      diffIDs, err := s.GetDiffIDs(ctx, key)
                  Severity: Major
                  Found in builder/builder-next/adapters/snapshot/layer.go - About 1 hr to fix

                    Method controller.Start has 15 return statements (exceeds 4 allowed).
                    Open

                    func (r *controller) Start(ctx context.Context) error {
                        if err := r.checkClosed(); err != nil {
                            return err
                        }
                    
                    
                    Severity: Major
                    Found in daemon/cluster/executor/container/controller.go - About 1 hr to fix

                      Method ImageService.ImageHistory has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (i *ImageService) ImageHistory(ctx context.Context, name string, platform *ocispec.Platform) ([]*imagetype.HistoryResponseItem, error) {
                          start := time.Now()
                          img, err := i.resolveImage(ctx, name)
                          if err != nil {
                              return nil, err
                      Severity: Minor
                      Found in daemon/containerd/image_history.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 ImageService.GetImageAndReleasableLayer has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
                          if refOrID == "" { // FROM scratch
                              if runtime.GOOS == "windows" {
                                  return nil, nil, fmt.Errorf(`"FROM scratch" is not supported on Windows`)
                              }
                      Severity: Minor
                      Found in daemon/containerd/image_builder.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

                      Function initClusterSpec has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func initClusterSpec(node *swarmnode.Node, spec types.Spec) error {
                          ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
                          defer cancel()
                          for conn := range node.ListenControlSocket(ctx) {
                              if ctx.Err() != nil {
                      Severity: Minor
                      Found in daemon/cluster/swarm.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.setWindowsCredentialSpec has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (daemon *Daemon) setWindowsCredentialSpec(c *container.Container, s *specs.Spec) error {
                          if c.HostConfig == nil || c.HostConfig.SecurityOpt == nil {
                              return nil
                          }
                      
                      
                      Severity: Minor
                      Found in daemon/oci_windows.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.fillRootlessVersion has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
                          if !rootless.RunningWithRootlessKit() {
                              return nil
                          }
                          rlc, err := getRootlessKitClient()
                      Severity: Minor
                      Found in daemon/info_unix.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 driver.NetworkAllocate has 60 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
                          if id == "" {
                              return nil, fmt.Errorf("invalid network id for overlay network")
                          }
                      
                      
                      Severity: Minor
                      Found in libnetwork/drivers/overlay/ovmanager/ovmanager.go - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language