dotcloud/docker

View on GitHub

Showing 1,885 of 1,885 total issues

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

func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, _ map[string]interface{}) error {
    if ifInfo == nil {
        return errors.New("invalid interface info passed")
    }

Severity: Minor
Found in libnetwork/drivers/bridge/bridge_linux.go - About 4 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

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

func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFunc, danglingOnly bool) (*image.PruneReport, error) {
    report := image.PruneReport{}

    allImages, err := i.images.List(ctx)
    if err != nil {
Severity: Minor
Found in daemon/containerd/image_prune.go - About 4 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 WithNamespaces has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
Open

func WithNamespaces(daemon *Daemon, c *container.Container) coci.SpecOpts {
    return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
        userNS := false
        // user
        if c.HostConfig.UsernsMode.IsPrivate() {
Severity: Minor
Found in daemon/oci_linux.go - About 4 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

Method walker.walk has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
Open

func (w *walker) walk(path string, i1, i2 os.FileInfo) (err error) {
    // Register these nodes with the return trees, unless we're still at the
    // (already-created) roots:
    if path != "/" {
        if err := walkchunk(path, i1, w.dir1, w.root1); err != nil {
Severity: Minor
Found in pkg/archive/changes_linux.go - About 4 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

Method PeerRecord.Unmarshal has 143 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

    Method PluginPrivilege.Unmarshal has 143 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (m *PluginPrivilege) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Major
    Found in api/types/swarm/runtime/plugin.pb.go - About 4 hrs to fix

      Function DefaultLinuxSpec has 142 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func DefaultLinuxSpec() specs.Spec {
          return specs.Spec{
              Version: specs.Version,
              Process: &specs.Process{
                  Capabilities: &specs.LinuxCapabilities{
      Severity: Major
      Found in oci/defaults.go - About 4 hrs to fix

        Method Daemon.buildSandboxOptions has 141 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (daemon *Daemon) buildSandboxOptions(cfg *config.Config, ctr *container.Container) ([]libnetwork.SandboxOption, error) {
            var sboxOptions []libnetwork.SandboxOption
            sboxOptions = append(sboxOptions, libnetwork.OptionHostname(ctr.Config.Hostname), libnetwork.OptionDomainname(ctr.Config.Domainname))
        
            if ctr.HostConfig.NetworkMode.IsHost() {
        Severity: Major
        Found in daemon/container_operations.go - About 4 hrs to fix

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

          func (ep *endpoint) UnmarshalJSON(b []byte) error {
              var (
                  err   error
                  epMap map[string]interface{}
              )
          Severity: Major
          Found in libnetwork/drivers/macvlan/macvlan_store.go and 1 other location - About 4 hrs to fix
          libnetwork/drivers/ipvlan/ipvlan_store.go on lines 262..292

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

          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 (ep *endpoint) UnmarshalJSON(b []byte) error {
              var (
                  err   error
                  epMap map[string]interface{}
              )
          Severity: Major
          Found in libnetwork/drivers/ipvlan/ipvlan_store.go and 1 other location - About 4 hrs to fix
          libnetwork/drivers/macvlan/macvlan_store.go on lines 256..286

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

          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 Cluster.CreateService has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
          Open

          func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRegistry bool) (*swarm.ServiceCreateResponse, error) {
              var resp *swarm.ServiceCreateResponse
              err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
                  err := c.populateNetworkID(ctx, state.controlClient, &s)
                  if err != nil {
          Severity: Minor
          Found in daemon/cluster/services.go - About 4 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

          Method driver.CreateEndpoint has 138 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, _ map[string]interface{}) error {
              if ifInfo == nil {
                  return errors.New("invalid interface info passed")
              }
          
          
          Severity: Major
          Found in libnetwork/drivers/bridge/bridge_linux.go - About 4 hrs to fix

            Function compare has 137 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func compare(a, b *container.Config) bool {
                if a == nil || b == nil {
                    return false
                }
            
            
            Severity: Major
            Found in image/cache/compare.go - About 4 hrs to fix

              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

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

                func getConfig(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Config, error) {
                    // attempt to lookup config by full ID
                    if rg, err := c.GetConfig(ctx, &swarmapi.GetConfigRequest{ConfigID: input}); err == nil {
                        return rg.Config, nil
                    }
                Severity: Major
                Found in daemon/cluster/helpers.go and 3 other locations - About 4 hrs to fix
                daemon/cluster/helpers.go on lines 26..60
                daemon/cluster/helpers.go on lines 106..140
                daemon/cluster/helpers.go on lines 142..176

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

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

                func getSecret(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Secret, error) {
                    // attempt to lookup secret by full ID
                    if rg, err := c.GetSecret(ctx, &swarmapi.GetSecretRequest{SecretID: input}); err == nil {
                        return rg.Secret, nil
                    }
                Severity: Major
                Found in daemon/cluster/helpers.go and 3 other locations - About 4 hrs to fix
                daemon/cluster/helpers.go on lines 26..60
                daemon/cluster/helpers.go on lines 106..140
                daemon/cluster/helpers.go on lines 178..212

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

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

                func getNode(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Node, error) {
                    // GetNode to match via full ID.
                    if rg, err := c.GetNode(ctx, &swarmapi.GetNodeRequest{NodeID: input}); err == nil {
                        return rg.Node, nil
                    }
                Severity: Major
                Found in daemon/cluster/helpers.go and 3 other locations - About 4 hrs to fix
                daemon/cluster/helpers.go on lines 106..140
                daemon/cluster/helpers.go on lines 142..176
                daemon/cluster/helpers.go on lines 178..212

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

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

                func getTask(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Task, error) {
                    // GetTask to match via full ID.
                    if rg, err := c.GetTask(ctx, &swarmapi.GetTaskRequest{TaskID: input}); err == nil {
                        return rg.Task, nil
                    }
                Severity: Major
                Found in daemon/cluster/helpers.go and 3 other locations - About 4 hrs to fix
                daemon/cluster/helpers.go on lines 26..60
                daemon/cluster/helpers.go on lines 142..176
                daemon/cluster/helpers.go on lines 178..212

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

                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 136 lines of code (exceeds 50 allowed). Consider refactoring.
                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 4 hrs to fix

                  Function withFetchProgress has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func withFetchProgress(cs content.Store, out progress.Output, ref reference.Named) images.HandlerFunc {
                      return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
                          switch desc.MediaType {
                          case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
                              tn := reference.TagNameOnly(ref)
                  Severity: Minor
                  Found in plugin/fetch_linux.go - About 4 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

                  Severity
                  Category
                  Status
                  Source
                  Language