dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

Function NodeFromGRPC has 65 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func NodeFromGRPC(n swarmapi.Node) types.Node {
    node := types.Node{
        ID: n.ID,
        Spec: types.NodeSpec{
            Role:         types.NodeRole(strings.ToLower(n.Spec.DesiredRole.String())),
Severity: Minor
Found in daemon/cluster/convert/node.go - About 1 hr to fix

    Method Daemon.findAndAttachNetwork has 65 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (daemon *Daemon) findAndAttachNetwork(ctr *container.Container, idOrName string, epConfig *networktypes.EndpointSettings) (*libnetwork.Network, *networktypes.NetworkingConfig, error) {
        id := getNetworkID(idOrName, epConfig)
    
        n, err := daemon.FindNetwork(id)
        if err != 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 (cli *Client) ContainerRestart(ctx context.Context, containerID string, options container.StopOptions) error {
          query := url.Values{}
          if options.Timeout != nil {
              query.Set("t", strconv.Itoa(*options.Timeout))
          }
      Severity: Major
      Found in client/container_restart.go and 1 other location - About 1 hr to fix
      client/container_stop.go on lines 19..40

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

      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 (cli *Client) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error {
          query := url.Values{}
          if options.Timeout != nil {
              query.Set("t", strconv.Itoa(*options.Timeout))
          }
      Severity: Major
      Found in client/container_stop.go and 1 other location - About 1 hr to fix
      client/container_restart.go on lines 15..36

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

      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 pusher.pushTag has 17 return statements (exceeds 4 allowed).
      Open

      func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id digest.Digest) error {
          log.G(ctx).Debugf("Pushing repository: %s", reference.FamiliarString(ref))
      
          imgConfig, err := p.config.ImageStore.Get(ctx, id)
          if err != nil {
      Severity: Major
      Found in distribution/push_v2.go - About 1 hr to fix

        Method puller.pullTag has 17 return statements (exceeds 4 allowed).
        Open

        func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *ocispec.Platform) (tagUpdated bool, err error) {
            var (
                tagOrDigest string // Used for logging/progress only
                dgst        digest.Digest
                mt          string
        Severity: Major
        Found in distribution/pull_v2.go - About 1 hr to fix

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

          func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id digest.Digest) error {
              log.G(ctx).Debugf("Pushing repository: %s", reference.FamiliarString(ref))
          
              imgConfig, err := p.config.ImageStore.Get(ctx, id)
              if err != nil {
          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 Controller.handleEpTableEvent has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
          Open

          func (c *Controller) handleEpTableEvent(ev events.Event) {
              var (
                  nid   string
                  eid   string
                  value []byte
          Severity: Minor
          Found in libnetwork/agent.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 PortAllocator.RequestPortsInRange has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p *PortAllocator) RequestPortsInRange(ips []net.IP, proto string, portStart, portEnd int) (int, error) {
              if proto != "tcp" && proto != "udp" && proto != "sctp" {
                  return 0, ErrUnknownProtocol
              }
          
          
          Severity: Minor
          Found in libnetwork/portallocator/portallocator.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 IPTable.ProgramChain has 17 return statements (exceeds 4 allowed).
          Open

          func (iptable IPTable) ProgramChain(c *ChainInfo, bridgeName string, hairpinMode, enable bool) error {
              if c.Name == "" {
                  return errors.New("could not program chain, missing chain name")
              }
          
          
          Severity: Major
          Found in libnetwork/iptables/iptables.go - About 1 hr to fix

            Method driver.Join has 17 return statements (exceeds 4 allowed).
            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: Major
            Found in libnetwork/drivers/overlay/joinleave.go - About 1 hr to fix

              Method linuxParser.validateMountConfigImpl has 17 return statements (exceeds 4 allowed).
              Open

              func (p *linuxParser) validateMountConfigImpl(mnt *mount.Mount, validateBindSourceExists bool) error {
                  if len(mnt.Target) == 0 {
                      return &errMountConfig{mnt, errMissingField("Target")}
                  }
              
              
              Severity: Major
              Found in volume/mounts/linux_parser.go - About 1 hr to fix

                Method Builder.Build has 17 return statements (exceeds 4 allowed).
                Open

                func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
                    if len(opt.Options.Outputs) > 1 {
                        return nil, errors.Errorf("multiple outputs not supported")
                    }
                
                
                Severity: Major
                Found in builder/builder-next/builder.go - About 1 hr to fix

                  Function ReadCertsDirectory has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error {
                      fs, err := os.ReadDir(directory)
                      if err != nil && !os.IsNotExist(err) {
                          return invalidParam(err)
                      }
                  Severity: Minor
                  Found in registry/registry.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.getPushDescriptor has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (i *ImageService) getPushDescriptor(ctx context.Context, img containerdimages.Image, platform *ocispec.Platform) (ocispec.Descriptor, error) {
                      pm := i.matchRequestedOrDefault(platforms.OnlyStrict, platform)
                  
                      anyMissing := false
                  
                  
                  Severity: Minor
                  Found in daemon/containerd/image_push.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.createDiff has 17 return statements (exceeds 4 allowed).
                  Open

                  func (i *ImageService) createDiff(ctx context.Context, name string, sn snapshots.Snapshotter, cs content.Store, comparer diff.Comparer) (*ocispec.Descriptor, digest.Digest, error) {
                      info, err := sn.Stat(ctx, name)
                      if err != nil {
                          return nil, "", err
                      }
                  Severity: Major
                  Found in daemon/containerd/image_commit.go - About 1 hr to fix

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

                    func (p *pushProgress) UpdateProgress(ctx context.Context, ongoing *jobs, out progress.Output, start time.Time) error {
                        for _, j := range ongoing.Jobs() {
                            key := remotes.MakeRefKey(ctx, j)
                            id := stringid.TruncateID(j.Digest.Encoded())
                    
                    
                    Severity: Minor
                    Found in daemon/containerd/progress.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.killWithSignal has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (daemon *Daemon) killWithSignal(container *containerpkg.Container, stopSignal syscall.Signal) error {
                        log.G(context.TODO()).Debugf("Sending kill signal %d to container %s", stopSignal, container.ID)
                        container.Lock()
                        defer container.Unlock()
                    
                    
                    Severity: Minor
                    Found in daemon/kill.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.Images has 17 return statements (exceeds 4 allowed).
                    Open

                    func (i *ImageService) Images(ctx context.Context, opts imagetypes.ListOptions) ([]*imagetypes.Summary, error) {
                        if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil {
                            return nil, err
                        }
                    
                    
                    Severity: Major
                    Found in daemon/images/image_list.go - About 1 hr to fix

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

                      func (daemon *Daemon) logServiceEvent(action swarmapi.WatchActionKind, service *swarmapi.Service, oldService *swarmapi.Service) {
                          attributes := map[string]string{
                              "name": service.Spec.Annotations.Name,
                          }
                          eventTime := eventTimestamp(service.Meta, action)
                      Severity: Minor
                      Found in daemon/events.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

                      Severity
                      Category
                      Status
                      Source
                      Language