dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Function New has 7 return statements (exceeds 4 allowed).
Open

func New(cfgOptions ...config.Option) (*Controller, error) {
    cfg := config.New(cfgOptions...)
    store, err := datastore.New(cfg.DataDir, cfg.DatastoreBucket)
    if err != nil {
        return nil, fmt.Errorf("libnet controller initialization: %w", err)
Severity: Major
Found in libnetwork/controller.go - About 45 mins to fix

    Method Controller.deleteEndpointNameResolution has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func (c *Controller) deleteEndpointNameResolution(svcName, svcID, nID, eID, containerName string, vip net.IP, serviceAliases, taskAliases []string, ip net.IP, rmService, multipleEntries bool, method string) error {
    Severity: Minor
    Found in libnetwork/service_common.go - About 45 mins to fix

      Method IPAMData.Validate has 7 return statements (exceeds 4 allowed).
      Open

      func (i *IPAMData) Validate() error {
          var isV6 bool
          if i.Pool == nil {
              return types.InvalidParameterErrorf("invalid pool")
          }
      Severity: Major
      Found in libnetwork/driverapi/ipamdata.go - About 45 mins to fix

        Method Sandbox.resolveName has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func (sb *Sandbox) resolveName(ctx context.Context, nameOrAlias string, networkName string, epList []*Endpoint, lookupAlias bool, ipType int) (_ []net.IP, ipv6Miss bool) {
        Severity: Minor
        Found in libnetwork/sandbox.go - About 45 mins to fix

          Method NetworkDB.handleNetworkEvent has 7 return statements (exceeds 4 allowed).
          Open

          func (nDB *NetworkDB) handleNetworkEvent(nEvent *NetworkEvent) bool {
              // Update our local clock if the received messages has newer
              // time.
              nDB.networkClock.Witness(nEvent.LTime)
          
          
          Severity: Major
          Found in libnetwork/networkdb/delegate.go - About 45 mins to fix

            Method driver.CreateNetwork has 7 return statements (exceeds 4 allowed).
            Open

            func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
                // reject a null v4 network if ipv4 is required
                if v, ok := option[netlabel.EnableIPv4]; ok && v.(bool) {
                    if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" {
                        return errdefs.InvalidParameter(fmt.Errorf("ipv4 pool is empty"))
            Severity: Major
            Found in libnetwork/drivers/macvlan/macvlan_network.go - About 45 mins to fix

              Function bindTCPOrUDP has 7 return statements (exceeds 4 allowed).
              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: Major
              Found in libnetwork/drivers/bridge/port_mapping_linux.go - About 45 mins to fix

                Method Endpoint.DriverInfo has 7 return statements (exceeds 4 allowed).
                Open

                func (ep *Endpoint) DriverInfo() (map[string]interface{}, error) {
                    ep, err := ep.retrieveFromStore()
                    if err != nil {
                        return nil, err
                    }
                Severity: Major
                Found in libnetwork/endpoint_info_windows.go - About 45 mins to fix

                  Method driver.CreateEndpoint has 7 return statements (exceeds 4 allowed).
                  Open

                  func (d *driver) CreateEndpoint(_ context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
                      var err error
                      if err = validateID(nid, eid); err != nil {
                          return err
                      }
                  Severity: Major
                  Found in libnetwork/drivers/overlay/ov_endpoint.go - About 45 mins to fix

                    Method driver.EventNotify has 7 return statements (exceeds 4 allowed).
                    Open

                    func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) {
                        if tableName != ovPeerTable {
                            log.G(context.TODO()).Errorf("Unexpected table notification for table %s received", tableName)
                            return
                        }
                    Severity: Major
                    Found in libnetwork/drivers/overlay/joinleave.go - About 45 mins to fix

                      Method PortMapper.MapRange has 7 return statements (exceeds 4 allowed).
                      Open

                      func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart, hostPortEnd int) (host net.Addr, retErr error) {
                          pm.lock.Lock()
                          defer pm.lock.Unlock()
                      
                          var (
                      Severity: Major
                      Found in libnetwork/portmapper/mapper.go - About 45 mins to fix

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

                        func (d *driver) createNetwork(config *networkConfiguration) (err error) {
                            // Initialize handle when needed
                            d.Lock()
                            if d.nlh.Handle == nil {
                                d.nlh = ns.NlHandle()
                        Severity: Minor
                        Found in libnetwork/drivers/bridge/bridge_linux.go - About 45 mins 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 NetworkDB.gossip has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (nDB *NetworkDB) gossip() {
                            networkNodes := make(map[string][]string)
                            nDB.RLock()
                            thisNodeNetworks := nDB.networks[nDB.config.NodeID]
                            for nid := range thisNodeNetworks {
                        Severity: Minor
                        Found in libnetwork/networkdb/cluster.go - About 45 mins 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 NewPortDriverClient has 7 return statements (exceeds 4 allowed).
                        Open

                        func NewPortDriverClient(ctx context.Context) (*PortDriverClient, error) {
                            stateDir := os.Getenv("ROOTLESSKIT_STATE_DIR")
                            if stateDir == "" {
                                return nil, errors.New("$ROOTLESSKIT_STATE_DIR needs to be set")
                            }
                        Severity: Major
                        Found in libnetwork/drivers/bridge/internal/rlkclient/rootlesskit_client_linux.go - About 45 mins to fix

                          Method driver.NetworkAllocate has 7 return statements (exceeds 4 allowed).
                          Open

                          func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
                              if id == "" {
                                  return nil, fmt.Errorf("invalid network id for overlay network")
                              }
                          
                          
                          Severity: Major
                          Found in libnetwork/drivers/overlay/ovmanager/ovmanager.go - About 45 mins to fix

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

                            func (d *driver) configure(option map[string]interface{}) error {
                                var (
                                    config            configuration
                                    err               error
                                    natChain          *iptables.ChainInfo
                            Severity: Minor
                            Found in libnetwork/drivers/bridge/bridge_linux.go - About 45 mins 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 createVlanLink has 7 return statements (exceeds 4 allowed).
                            Open

                            func createVlanLink(parentName string) error {
                                if strings.Contains(parentName, ".") {
                                    parent, vidInt, err := parseVlan(parentName)
                                    if err != nil {
                                        return err
                            Severity: Major
                            Found in libnetwork/drivers/macvlan/macvlan_setup.go - About 45 mins to fix

                              Method networkConfiguration.Validate has 7 return statements (exceeds 4 allowed).
                              Open

                              func (c *networkConfiguration) Validate() error {
                                  if c.Mtu < 0 {
                                      return ErrInvalidMtu(c.Mtu)
                                  }
                              
                              
                              Severity: Major
                              Found in libnetwork/drivers/bridge/bridge_linux.go - About 45 mins to fix

                                Method cnmNetworkAllocator.IsServiceAllocated has 7 return statements (exceeds 4 allowed).
                                Open

                                func (na *cnmNetworkAllocator) IsServiceAllocated(s *api.Service, flags ...func(*networkallocator.ServiceAllocationOpts)) bool {
                                    specNetworks := serviceNetworks(s)
                                
                                    // If endpoint mode is VIP and allocator does not have the
                                    // service in VIP allocated set then it needs to be allocated.
                                Severity: Major
                                Found in libnetwork/cnmallocator/networkallocator.go - About 45 mins to fix

                                  Method Store.lookup has 7 return statements (exceeds 4 allowed).
                                  Open

                                  func (s *Store) lookup(name string, mode int) (volume.Driver, error) {
                                      if name == "" {
                                          return nil, errdefs.InvalidParameter(errors.New("driver name cannot be empty"))
                                      }
                                      s.driverLock.Lock(name)
                                  Severity: Major
                                  Found in volume/drivers/extpoint.go - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language