dotcloud/docker

View on GitHub

Showing 1,904 of 1,904 total issues

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

        case 8:
            if wireType != 2 {
                return fmt.Errorf("proto: wrong wireType = %d for field TaskAliases", wireType)
            }
            var stringLen uint64
Severity: Major
Found in libnetwork/agent.pb.go and 4 other locations - About 2 hrs to fix
api/types/swarm/runtime/plugin.pb.go on lines 526..557
api/types/swarm/runtime/plugin.pb.go on lines 672..703
libnetwork/agent.pb.go on lines 841..872
libnetwork/networkdb/networkdb.pb.go on lines 2753..2784

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

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

        case 3:
            if wireType != 2 {
                return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
            }
            var stringLen uint64
Severity: Major
Found in api/types/swarm/runtime/plugin.pb.go and 4 other locations - About 2 hrs to fix
api/types/swarm/runtime/plugin.pb.go on lines 526..557
libnetwork/agent.pb.go on lines 841..872
libnetwork/agent.pb.go on lines 873..904
libnetwork/networkdb/networkdb.pb.go on lines 2753..2784

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

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 Controller.handleKeyChange has 87 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *Controller) handleKeyChange(keys []*types.EncryptionKey) error {
    drvEnc := discoverapi.DriverEncryptionUpdate{}

    agent := c.getAgent()
    if agent == nil {
Severity: Major
Found in libnetwork/agent.go - About 2 hrs to fix

    Method Client.imageBuildOptionsToQuery has 87 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options types.ImageBuildOptions) (url.Values, error) {
        query := url.Values{
            "t":           options.Tags,
            "securityopt": options.SecurityOpt,
            "extrahosts":  options.ExtraHosts,
    Severity: Major
    Found in client/image_build.go - About 2 hrs to fix

      Method ImageService.ImageInspect has 87 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
          img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{})
          if err != nil {
              return nil, err
          }
      Severity: Major
      Found in daemon/containerd/image_inspect.go - About 2 hrs to fix

        Method Endpoint.sbLeave has 86 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (ep *Endpoint) sbLeave(ctx context.Context, sb *Sandbox, force bool) error {
            n, err := ep.getNetworkFromStore()
            if err != nil {
                return fmt.Errorf("failed to get network from store during leave: %v", err)
            }
        Severity: Major
        Found in libnetwork/endpoint.go - About 2 hrs to fix

          Function StartProxy has 86 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func StartProxy(pb types.PortBinding,
              proxyPath string,
              listenSock *os.File,
          ) (stop func() error, retErr error) {
              if proxyPath == "" {
          Severity: Major
          Found in libnetwork/portmapper/proxy_linux.go - About 2 hrs to fix

            Method Daemon.statsV1 has 86 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (daemon *Daemon) statsV1(s *containertypes.StatsResponse, stats *statsV1.Metrics) (*containertypes.StatsResponse, error) {
                if stats.Blkio != nil {
                    s.BlkioStats = containertypes.BlkioStats{
                        IoServiceBytesRecursive: copyBlkioEntry(stats.Blkio.IoServiceBytesRecursive),
                        IoServicedRecursive:     copyBlkioEntry(stats.Blkio.IoServicedRecursive),
            Severity: Major
            Found in daemon/stats_unix.go - About 2 hrs to fix

              Method addrSpace.allocatePredefinedPool has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
              Open

              func (aSpace *addrSpace) allocatePredefinedPool(reserved []netip.Prefix) (netip.Prefix, error) {
                  aSpace.mu.Lock()
                  defer aSpace.mu.Unlock()
              
                  var pdfID int
              Severity: Minor
              Found in libnetwork/ipams/defaultipam/address_space.go - About 2 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 27 return statements (exceeds 4 allowed).
              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 2 hrs to fix

                Method NetworkEntry.Unmarshal has 27 return statements (exceeds 4 allowed).
                Open

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

                  Method NetworkEvent.Unmarshal has 27 return statements (exceeds 4 allowed).
                  Open

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

                    Function newImageBuildOptions has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBuildOptions, error) {
                        options := &types.ImageBuildOptions{
                            Version:        types.BuilderV1, // Builder V1 is the default, but can be overridden
                            Dockerfile:     r.FormValue("dockerfile"),
                            SuppressOutput: httputils.BoolValue(r, "q"),
                    Severity: Minor
                    Found in api/server/router/build/build_routes.go - About 2 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 PluginPrivilege.Unmarshal has 27 return statements (exceeds 4 allowed).
                    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 2 hrs to fix

                      Method Cluster.GetTasks has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (c *Cluster) GetTasks(options apitypes.TaskListOptions) ([]types.Task, error) {
                          var r *swarmapi.ListTasksResponse
                      
                          err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
                              filterTransform := func(filter filters.Args) error {
                      Severity: Minor
                      Found in daemon/cluster/tasks.go - About 2 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 Parse has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func Parse(filePath string, objName string) (*ParsedPkg, error) {
                          fs := token.NewFileSet()
                          pkg, err := parser.ParseFile(fs, filePath, nil, parser.AllErrors)
                          if err != nil {
                              return nil, err
                      Severity: Minor
                      Found in pkg/plugins/pluginrpc-gen/parser.go - About 2 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 DisplayJSONMessagesStream has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(JSONMessage)) error {
                          var (
                              dec = json.NewDecoder(in)
                              ids = make(map[string]uint)
                          )
                      Severity: Minor
                      Found in pkg/jsonmessage/jsonmessage.go - About 2 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

                      File resolver.go has 516 lines of code (exceeds 500 allowed). Consider refactoring.
                      Open

                      package libnetwork
                      
                      import (
                          "context"
                          "errors"
                      Severity: Minor
                      Found in libnetwork/resolver.go - About 2 hrs to fix

                        File controller.go has 516 lines of code (exceeds 500 allowed). Consider refactoring.
                        Open

                        package container // import "github.com/docker/docker/daemon/cluster/executor/container"
                        
                        import (
                            "context"
                            "fmt"
                        Severity: Minor
                        Found in daemon/cluster/executor/container/controller.go - About 2 hrs to fix

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

                          func delVlanLink(linkName string) error {
                              if strings.Contains(linkName, ".") {
                                  _, _, err := parseVlan(linkName)
                                  if err != nil {
                                      return err
                          Severity: Major
                          Found in libnetwork/drivers/ipvlan/ipvlan_setup.go and 1 other location - About 2 hrs to fix
                          libnetwork/drivers/macvlan/macvlan_setup.go on lines 114..138

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

                          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