dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

Method NodeEvent.Unmarshal has 21 return statements (exceeds 4 allowed).
Open

func (m *NodeEvent) 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

    Function newProxy has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
    Open

    func newProxy(config ProxyConfig) (p Proxy, err error) {
        ipv := ipv4
        if config.HostIP.To4() == nil {
            ipv = ipv6
        }
    Severity: Minor
    Found in cmd/docker-proxy/main_linux.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 PartialLogEntryMetadata.Unmarshal has 21 return statements (exceeds 4 allowed).
    Open

    func (m *PartialLogEntryMetadata) Unmarshal(dAtA []byte) error {
        l := len(dAtA)
        iNdEx := 0
        for iNdEx < l {
            preIndex := iNdEx
    Severity: Major
    Found in api/types/plugins/logdriver/entry.pb.go - About 1 hr to fix

      Method reader.drainJournal has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func (r *reader) drainJournal(ctx context.Context) (bool, error) {
          for i := 0; ; i++ {
              // Read the entry's timestamp.
              timestamp, err := r.j.Realtime()
              if err != nil {
      Severity: Minor
      Found in daemon/logger/journald/read.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.foldFilter has 21 return statements (exceeds 4 allowed).
      Open

      func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, config *containertypes.ListOptions) (*listContext, error) {
          psFilters := config.Filters
      
          var filtExited []int
      
      
      Severity: Major
      Found in daemon/list.go - About 1 hr to fix

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

        package client // import "github.com/docker/docker/client"
        
        import (
            "context"
            "encoding/json"
        Severity: Major
        Found in client/config_create.go and 1 other location - About 1 hr to fix
        client/secret_create.go on lines 1..25

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

        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

        package client // import "github.com/docker/docker/client"
        
        import (
            "context"
            "encoding/json"
        Severity: Major
        Found in client/secret_create.go and 1 other location - About 1 hr to fix
        client/config_create.go on lines 1..25

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

        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 resolveContainerSpecImage(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
            var warning string
            if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.ContainerSpec.Image, encodedAuth); err != nil {
                warning = digestWarning(taskSpec.ContainerSpec.Image)
            } else {
        Severity: Major
        Found in client/service_create.go and 1 other location - About 1 hr to fix
        client/service_create.go on lines 100..114

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

        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 resolvePluginSpecRemote(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
            var warning string
            if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.PluginSpec.Remote, encodedAuth); err != nil {
                warning = digestWarning(taskSpec.PluginSpec.Remote)
            } else {
        Severity: Major
        Found in client/service_create.go and 1 other location - About 1 hr to fix
        client/service_create.go on lines 84..98

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

        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 72 lines of code (exceeds 50 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 1 hr to fix

          Function convertMount has 72 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func convertMount(m api.Mount) enginemount.Mount {
              mount := enginemount.Mount{
                  Source:   m.Source,
                  Target:   m.Target,
                  ReadOnly: m.ReadOnly,
          Severity: Minor
          Found in daemon/cluster/executor/container/container.go - About 1 hr to fix

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

            func (d *driver) populateNetworks() error {
                kvol, err := d.store.List(&configuration{})
                if err != nil && err != datastore.ErrKeyNotFound {
                    return fmt.Errorf("failed to get macvlan network configurations from store: %v", err)
                }
            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 66..83

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

            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 (d *driver) populateNetworks() error {
                kvol, err := d.store.List(&configuration{})
                if err != nil && err != datastore.ErrKeyNotFound {
                    return fmt.Errorf("failed to get ipvlan network configurations from store: %v", err)
                }
            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 65..82

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

            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 snapshotter.EnsureLayer has 71 lines of code (exceeds 50 allowed). Consider refactoring.
            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: Minor
            Found in builder/builder-next/adapters/snapshot/layer.go - About 1 hr to fix

              Method Reader.testTail has 71 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (tr Reader) testTail(t *testing.T, live bool) {
                  t.Parallel()
                  factory := tr.Factory(t, logger.Info{
                      ContainerID:   "tailtest0000",
                      ContainerName: "logtail",
              Severity: Minor
              Found in daemon/logger/loggertest/logreader.go - About 1 hr to fix

                Method layerStore.registerWithDescriptor has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, descriptor distribution.Descriptor) (Layer, error) {
                    // cErr is used to hold the error which will always trigger
                    // cleanup of creates sources but may not be an error returned
                    // to the caller (already exists).
                    var cErr error
                Severity: Minor
                Found in layer/layer_store.go - About 1 hr to fix

                  Method windowsParser.validateMountConfigReg has 20 return statements (exceeds 4 allowed).
                  Open

                  func (p *windowsParser) validateMountConfigReg(mnt *mount.Mount, additionalValidators ...mountValidator) error {
                      if len(mnt.Target) == 0 {
                          return &errMountConfig{mnt, errMissingField("Target")}
                      }
                      for _, v := range additionalValidators {
                  Severity: Major
                  Found in volume/mounts/windows_parser.go - About 1 hr to fix

                    Function UnpackLayer has 20 return statements (exceeds 4 allowed).
                    Open

                    func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, err error) {
                        tr := tar.NewReader(layer)
                        trBuf := pools.BufioReader32KPool.Get(tr)
                        defer pools.BufioReader32KPool.Put(trBuf)
                    
                    
                    Severity: Major
                    Found in pkg/archive/diff.go - About 1 hr to fix

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

                      func (s *containerRouter) postContainersPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                          if err := httputils.ParseForm(r); err != nil {
                              return err
                          }
                      
                      
                      Severity: Major
                      Found in api/server/router/container/container_routes.go and 2 other locations - About 1 hr to fix
                      api/server/router/image/image_routes.go on lines 509..524
                      api/server/router/network/network_routes.go on lines 295..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 180.

                      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

                      func (n *networkRouter) postNetworksPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                          if err := httputils.ParseForm(r); err != nil {
                              return err
                          }
                      
                      
                      Severity: Major
                      Found in api/server/router/network/network_routes.go and 2 other locations - About 1 hr to fix
                      api/server/router/image/image_routes.go on lines 509..524
                      api/server/router/container/container_routes.go on lines 1057..1072

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

                      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