dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

func New(name string, config Options) (Driver, error) {
    ctx := context.TODO()
    if name != "" {
        log.G(ctx).Infof("[graphdriver] trying configured driver: %s", name)
        if err := checkRemoved(name); err != nil {
Severity: Minor
Found in daemon/graphdriver/driver.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.handleContainerExit has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontainerdtypes.EventInfo) error {
    var exitStatus container.ExitStatus
    c.Lock()

    cfg := daemon.config()
Severity: Minor
Found in daemon/monitor.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.filterByNameIDMatches has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (daemon *Daemon) filterByNameIDMatches(view *container.View, filter *listContext) ([]container.Snapshot, error) {
    idSearch := false
    names := filter.filters.Get("name")
    ids := filter.filters.Get("id")
    if len(names)+len(ids) == 0 {
Severity: Minor
Found in daemon/list.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 parseUintList has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func parseUintList(val string, maximum int) (map[int]bool, error) {
    if val == "" {
        return map[int]bool{}, nil
    }

Severity: Minor
Found in pkg/parsers/parsers.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 tarSum.Read has 17 return statements (exceeds 4 allowed).
Open

func (ts *tarSum) Read(buf []byte) (int, error) {
    if ts.finished {
        return ts.bufWriter.Read(buf)
    }
    if len(ts.bufData) < len(buf) {
Severity: Major
Found in pkg/tarsum/tarsum.go - About 1 hr to fix

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

            switch s.UpdateStatus.State {
            case swarmapi.UpdateStatus_UPDATING:
                service.UpdateStatus.State = types.UpdateStateUpdating
            case swarmapi.UpdateStatus_PAUSED:
                service.UpdateStatus.State = types.UpdateStatePaused
    Severity: Major
    Found in daemon/cluster/convert/service.go and 1 other location - About 1 hr to fix
    daemon/cluster/executor/container/container.go on lines 322..335

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

    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

            switch m.BindOptions.Propagation {
            case api.MountPropagationRPrivate:
                mount.BindOptions.Propagation = enginemount.PropagationRPrivate
            case api.MountPropagationPrivate:
                mount.BindOptions.Propagation = enginemount.PropagationPrivate
    Severity: Major
    Found in daemon/cluster/executor/container/container.go and 1 other location - About 1 hr to fix
    daemon/cluster/convert/service.go on lines 59..72

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

    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 cnmNetworkAllocator.AllocateService has 64 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (na *cnmNetworkAllocator) AllocateService(s *api.Service) (err error) {
        defer func() {
            if err != nil {
                na.DeallocateService(s)
            }
    Severity: Minor
    Found in libnetwork/cnmallocator/networkallocator.go - About 1 hr to fix

      Function dispatch has 64 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func dispatch(ctx context.Context, d dispatchRequest, cmd instructions.Command) (err error) {
          if c, ok := cmd.(instructions.PlatformSpecific); ok {
              err := c.CheckPlatform(d.state.operatingSystem)
              if err != nil {
                  return errdefs.InvalidParameter(err)
      Severity: Minor
      Found in builder/dockerfile/evaluator.go - About 1 hr to fix

        Method cacheAdaptor.Get has 64 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
            ctx := context.TODO()
            ref := id.String()
        
            outImg, err := c.is.GetImage(ctx, id.String(), backend.GetImageOpts{})
        Severity: Minor
        Found in daemon/containerd/cache.go - About 1 hr to fix

          Method ImageService.resolveImage has 64 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (i *ImageService) resolveImage(ctx context.Context, refOrID string) (containerdimages.Image, error) {
              parsed, err := reference.ParseAnyReference(refOrID)
              if err != nil {
                  return containerdimages.Image{}, errdefs.InvalidParameter(err)
              }
          Severity: Minor
          Found in daemon/containerd/image.go - About 1 hr to fix

            Method Daemon.killWithSignal has 64 lines of code (exceeds 50 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

              Method splunkLogger.tryPostMessages has 64 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (l *splunkLogger) tryPostMessages(ctx context.Context, messages []*splunkMessage) error {
                  if len(messages) == 0 {
                      return nil
                  }
                  var buffer bytes.Buffer
              Severity: Minor
              Found in daemon/logger/splunk/splunk.go - About 1 hr to fix

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

                func (config *configuration) processIPAM(ipamV4Data, ipamV6Data []driverapi.IPAMData) {
                    for _, ipd := range ipamV4Data {
                        config.Ipv4Subnets = append(config.Ipv4Subnets, &ipSubnet{
                            SubnetIP: ipd.Pool.String(),
                            GwIP:     ipd.Gateway.String(),
                Severity: Major
                Found in libnetwork/drivers/ipvlan/ipvlan_network.go and 1 other location - About 1 hr to fix
                libnetwork/drivers/macvlan/macvlan_network.go on lines 269..282

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

                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 (config *configuration) processIPAM(ipamV4Data, ipamV6Data []driverapi.IPAMData) {
                    for _, ipd := range ipamV4Data {
                        config.Ipv4Subnets = append(config.Ipv4Subnets, &ipSubnet{
                            SubnetIP: ipd.Pool.String(),
                            GwIP:     ipd.Gateway.String(),
                Severity: Major
                Found in libnetwork/drivers/macvlan/macvlan_network.go and 1 other location - About 1 hr to fix
                libnetwork/drivers/ipvlan/ipvlan_network.go on lines 263..276

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

                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 (d *driver) initStore(option map[string]interface{}) error {
                    if data, ok := option[netlabel.LocalKVClient]; ok {
                        var ok bool
                        d.store, ok = data.(*datastore.Store)
                        if !ok {
                Severity: Major
                Found in libnetwork/drivers/ipvlan/ipvlan_store.go and 1 other location - About 1 hr to fix
                libnetwork/drivers/macvlan/macvlan_store.go on lines 43..62

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

                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 (d *driver) initStore(option map[string]interface{}) error {
                    if data, ok := option[netlabel.LocalKVClient]; ok {
                        var ok bool
                        d.store, ok = data.(*datastore.Store)
                        if !ok {
                Severity: Major
                Found in libnetwork/drivers/macvlan/macvlan_store.go and 1 other location - About 1 hr to fix
                libnetwork/drivers/ipvlan/ipvlan_store.go on lines 44..63

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

                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

                        if c.Privileges.Seccomp != nil {
                            containerSpec.Privileges.Seccomp = &types.SeccompOpts{
                                Profile: c.Privileges.Seccomp.Profile,
                            }
                
                
                Severity: Major
                Found in daemon/cluster/convert/container.go and 1 other location - About 1 hr to fix
                daemon/cluster/convert/container.go on lines 344..357

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

                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

                        if c.Privileges.Seccomp != nil {
                            containerSpec.Privileges.Seccomp = &swarmapi.Privileges_SeccompOpts{
                                Profile: c.Privileges.Seccomp.Profile,
                            }
                
                
                Severity: Major
                Found in daemon/cluster/convert/container.go and 1 other location - About 1 hr to fix
                daemon/cluster/convert/container.go on lines 74..87

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

                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 RestartManager.ShouldRestart has 63 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (rm *RestartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped bool, executionDuration time.Duration) (bool, chan error, error) {
                    if rm.policy.IsNone() {
                        return false, nil, nil
                    }
                    rm.Lock()
                Severity: Minor
                Found in restartmanager/restartmanager.go - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language