dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method Client.callWithRetry has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool, reqOpts ...func(*RequestOpts)) (io.ReadCloser, error) {
    var retries int
    start := time.Now()

    var opts RequestOpts
Severity: Minor
Found in pkg/plugins/client.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.fillRootlessVersion has 13 return statements (exceeds 4 allowed).
Open

func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
    if !rootless.RunningWithRootlessKit() {
        return nil
    }
    rlc, err := getRootlessKitClient()
Severity: Major
Found in daemon/info_unix.go - About 1 hr to fix

    Function pullEndpoints has 56 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func pullEndpoints(ctx context.Context, registryService RegistryResolver, ref reference.Named,
        f func(context.Context, registry.RepositoryInfo, registry.APIEndpoint) error,
    ) (*registry.RepositoryInfo, error) {
        // Resolve the Repository name from fqn to RepositoryInfo
        repoInfo, err := registryService.ResolveRepository(ref)
    Severity: Minor
    Found in distribution/pull.go - About 1 hr to fix

      Function Client has 56 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func Client(args []string) {
          log.G(context.TODO()).Infof("[CLIENT] Starting with arguments %v", args)
          command := args[0]
      
          if len(args) < cmdArgCheck[command] {
      Severity: Minor
      Found in libnetwork/cmd/networkdb-test/dbclient/ndbClient.go - About 1 hr to fix

        Method Namespace.AddNeighbor has 56 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (n *Namespace) AddNeighbor(dstIP net.IP, dstMac net.HardwareAddr, force bool, options ...NeighOption) error {
            var (
                iface                  netlink.Link
                err                    error
                neighborAlreadyPresent bool
        Severity: Minor
        Found in libnetwork/osl/neigh_linux.go - About 1 hr to fix

          Function bindTCPOrUDP has 56 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func bindTCPOrUDP(cfg portBindingReq, port, typ, proto int) (_ portBinding, retErr error) {
              pb := portBinding{PortBinding: cfg.PortBinding.GetCopy()}
              pb.HostPort = uint16(port)
              pb.HostPortEnd = pb.HostPort
              pb.childHostIP = cfg.childHostIP
          Severity: Minor
          Found in libnetwork/drivers/bridge/port_mapping_linux.go - About 1 hr to fix

            Method VolumeStore.restore has 56 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (s *VolumeStore) restore() {
                var ls []volumeMetadata
                s.db.View(func(tx *bolt.Tx) error {
                    ls = listMeta(tx)
                    return nil
            Severity: Minor
            Found in volume/service/restore.go - About 1 hr to fix

              Function adjustForAPIVersion has 56 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func adjustForAPIVersion(cliVersion string, service *swarm.ServiceSpec) {
                  if cliVersion == "" {
                      return
                  }
                  if versions.LessThan(cliVersion, "1.46") {
              Severity: Minor
              Found in api/server/router/swarm/helpers.go - About 1 hr to fix

                Method containerRouter.postContainersAttach has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (c *containerRouter) postContainersAttach(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
                    err := httputils.ParseForm(r)
                    if err != nil {
                        return err
                    }
                Severity: Minor
                Found in api/server/router/container/container_routes.go - About 1 hr to fix

                  Method Cluster.Leave has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (c *Cluster) Leave(ctx context.Context, force bool) error {
                      c.controlMutex.Lock()
                      defer c.controlMutex.Unlock()
                  
                      c.mu.Lock()
                  Severity: Minor
                  Found in daemon/cluster/swarm.go - About 1 hr to fix

                    Function validateEndpointSettings has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func validateEndpointSettings(nw *libnetwork.Network, nwName string, epConfig *networktypes.EndpointSettings) error {
                        if epConfig == nil {
                            return nil
                        }
                    
                    
                    Severity: Minor
                    Found in daemon/container_operations.go - About 1 hr to fix

                      Method Daemon.CreateImageFromContainer has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (daemon *Daemon) CreateImageFromContainer(ctx context.Context, name string, c *backend.CreateImageConfig) (string, error) {
                          start := time.Now()
                      
                          container, err := daemon.GetContainer(name)
                          if err != nil {
                      Severity: Minor
                      Found in daemon/commit.go - About 1 hr to fix

                        Method Client.callWithRetry has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool, reqOpts ...func(*RequestOpts)) (io.ReadCloser, error) {
                            var retries int
                            start := time.Now()
                        
                            var opts RequestOpts
                        Severity: Minor
                        Found in pkg/plugins/client.go - About 1 hr to fix

                          Function computePrivileges has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func computePrivileges(c types.PluginConfig) types.PluginPrivileges {
                              var privileges types.PluginPrivileges
                              if c.Network.Type != "null" && c.Network.Type != "bridge" && c.Network.Type != "" {
                                  privileges = append(privileges, types.PluginPrivilege{
                                      Name:        "network",
                          Severity: Minor
                          Found in plugin/backend_linux.go - About 1 hr to fix

                            Method NetworkDB.handleTableEvent has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent, isBulkSync bool) bool {
                                // Update our local clock if the received messages has newer time.
                                nDB.tableClock.Witness(tEvent.LTime)
                            
                                // Ignore the table events for networks that are in the process of going away
                            Severity: Minor
                            Found in libnetwork/networkdb/delegate.go - About 1 hr to fix

                              Method PortAllocator.RequestPortsInRange has 55 lines of code (exceeds 50 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

                                Function programSA has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func programSA(localIP, remoteIP net.IP, spi *spi, k *key, dir int, add bool) (fSA *netlink.XfrmState, rSA *netlink.XfrmState, err error) {
                                    var (
                                        action      = "Removing"
                                        xfrmProgram = ns.NlHandle().XfrmStateDel
                                    )
                                Severity: Minor
                                Found in libnetwork/drivers/overlay/encryption.go - About 1 hr to fix

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

                                  func (d *driver) CreateEndpoint(_ context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) (retErr error) {
                                      if ifInfo == nil {
                                          return errors.New("must not be called with nil InterfaceInfo")
                                      }
                                  
                                  
                                  Severity: Minor
                                  Found in libnetwork/drivers/remote/driver.go - About 1 hr to fix

                                    Method TableEvent.MarshalToSizedBuffer has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func (m *TableEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                                        i := len(dAtA)
                                        _ = i
                                        var l int
                                        _ = l
                                    Severity: Minor
                                    Found in libnetwork/networkdb/networkdb.pb.go - About 1 hr to fix

                                      Method linuxParser.ParseMountRaw has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                                      Open

                                      func (p *linuxParser) ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) {
                                          arr := strings.SplitN(raw, ":", 4)
                                          if arr[0] == "" {
                                              return nil, errInvalidSpec(raw)
                                          }
                                      Severity: Minor
                                      Found in volume/mounts/linux_parser.go - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language