dotcloud/docker

View on GitHub

Showing 1,468 of 1,914 total issues

Method Cluster.resolveSystemAddrViaSubnetCheck has 62 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *Cluster) resolveSystemAddrViaSubnetCheck() (net.IP, error) {
    // Use the system's only IP address, or fail if there are
    // multiple addresses to choose from. Skip interfaces which
    // are managed by docker via subnet check.
    interfaces, err := net.Interfaces()
Severity: Minor
Found in daemon/cluster/listen_addr.go - About 1 hr to fix

    Method ImageService.ImageInspect has 62 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: Minor
    Found in daemon/images/image_inspect.go - About 1 hr to fix

      Function New has 62 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func New(c testing.TB, name string, files map[string]string, enforceLocalServer bool) *FakeGit {
          c.Helper()
          ctx := fakecontext.New(c, "", fakecontext.WithFiles(files))
          defer ctx.Close()
          curdir, err := os.Getwd()
      Severity: Minor
      Found in testutil/fakegit/fakegit.go - About 1 hr to fix

        Method ResolvConf.Generate has 61 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (rc *ResolvConf) Generate(comments bool) ([]byte, error) {
            s := struct {
                Md          *metadata
                NameServers []netip.Addr
                Search      []string
        Severity: Minor
        Found in libnetwork/internal/resolvconf/resolvconf.go - About 1 hr to fix

          Function setupIPChains has 61 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func setupIPChains(config configuration, version iptables.IPVersion) (natChain *iptables.ChainInfo, filterChain *iptables.ChainInfo, isolationChain1 *iptables.ChainInfo, isolationChain2 *iptables.ChainInfo, retErr error) {
              // Sanity check.
              if version == iptables.IPv4 && !config.EnableIPTables {
                  return nil, nil, nil, nil, errors.New("cannot create new chains, iptables is disabled")
              }
          Severity: Minor
          Found in libnetwork/drivers/bridge/setup_ip_tables_linux.go - About 1 hr to fix

            Method Service.lookupV2Endpoints has 61 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, err error) {
                ana := s.config.allowNondistributableArtifacts(hostname)
            
                if hostname == DefaultNamespace || hostname == IndexHostname {
                    for _, mirror := range s.config.Mirrors {
            Severity: Minor
            Found in registry/service_v2.go - About 1 hr to fix

              Method ImageService.getPushDescriptor has 61 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (i *ImageService) getPushDescriptor(ctx context.Context, img containerdimages.Image, platform *ocispec.Platform) (ocispec.Descriptor, error) {
                  pm := i.matchRequestedOrDefault(platforms.OnlyStrict, platform)
              
                  anyMissing := false
              
              
              Severity: Minor
              Found in daemon/containerd/image_push.go - About 1 hr to fix

                Method Daemon.allocateNetwork has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (daemon *Daemon) allocateNetwork(ctx context.Context, cfg *config.Config, ctr *container.Container) (retErr error) {
                    if daemon.netController == nil {
                        return nil
                    }
                
                
                Severity: Minor
                Found in daemon/container_operations.go - About 1 hr to fix

                  Method pushDescriptor.layerAlreadyExists has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (pd *pushDescriptor) layerAlreadyExists(
                      ctx context.Context,
                      progressOutput progress.Output,
                      diffID layer.DiffID,
                      checkOtherRepositories bool,
                  Severity: Minor
                  Found in distribution/push_v2.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 layerDescriptor.Download has 15 return statements (exceeds 4 allowed).
                  Open

                  func (ld *layerDescriptor) Download(ctx context.Context, progressOutput progress.Output) (io.ReadCloser, int64, error) {
                      log.G(ctx).Debugf("pulling blob %q", ld.digest)
                  
                      var (
                          err    error
                  Severity: Major
                  Found in distribution/pull_v2.go - About 1 hr to fix

                    Method tarexporter.legacyLoadImage has 15 return statements (exceeds 4 allowed).
                    Open

                    func (l *tarexporter) legacyLoadImage(oldID, sourceDir string, loadedMap map[string]image.ID, progressOutput progress.Output) error {
                        if _, loaded := loadedMap[oldID]; loaded {
                            return nil
                        }
                        configPath, err := safePath(sourceDir, filepath.Join(oldID, legacyConfigFileName))
                    Severity: Major
                    Found in image/tarexport/load.go - About 1 hr to fix

                      Method CompoundMessage_SimpleMessage.Unmarshal has 15 return statements (exceeds 4 allowed).
                      Open

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

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

                        func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
                            ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.overlay.Join", trace.WithAttributes(
                                attribute.String("nid", nid),
                                attribute.String("eid", eid),
                                attribute.String("sboxKey", sboxKey)))
                        Severity: Minor
                        Found in libnetwork/drivers/overlay/joinleave.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 skipOverlay has 15 return statements (exceeds 4 allowed).
                        Open

                        func skipOverlay(dAtA []byte) (n int, err error) {
                            l := len(dAtA)
                            iNdEx := 0
                            for iNdEx < l {
                                var wire uint64
                        Severity: Major
                        Found in libnetwork/drivers/windows/overlay/overlay.pb.go - About 1 hr to fix

                          Method snapshotter.EnsureLayer has 15 return statements (exceeds 4 allowed).
                          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: Major
                          Found in builder/builder-next/adapters/snapshot/layer.go - About 1 hr to fix

                            Method imageExporterInstance.Export has 15 return statements (exceeds 4 allowed).
                            Open

                            func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source, inlineCache exptypes.InlineCache, sessionID string) (map[string]string, exporter.DescriptorReference, error) {
                                if len(inp.Refs) > 1 {
                                    return nil, nil, fmt.Errorf("exporting multiple references to image store is currently unsupported")
                                }
                            
                            
                            Severity: Major
                            Found in builder/builder-next/exporter/mobyexporter/export.go - About 1 hr to fix

                              Method controller.Start has 15 return statements (exceeds 4 allowed).
                              Open

                              func (r *controller) Start(ctx context.Context) error {
                                  if err := r.checkClosed(); err != nil {
                                      return err
                                  }
                              
                              
                              Severity: Major
                              Found in daemon/cluster/executor/container/controller.go - About 1 hr to fix

                                Method ImageService.ImageHistory has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                                Open

                                func (i *ImageService) ImageHistory(ctx context.Context, name string, platform *ocispec.Platform) ([]*imagetype.HistoryResponseItem, error) {
                                    start := time.Now()
                                    img, err := i.resolveImage(ctx, name)
                                    if err != nil {
                                        return nil, err
                                Severity: Minor
                                Found in daemon/containerd/image_history.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 ImageService.getPushDescriptor has 15 return statements (exceeds 4 allowed).
                                Open

                                func (i *ImageService) getPushDescriptor(ctx context.Context, img containerdimages.Image, platform *ocispec.Platform) (ocispec.Descriptor, error) {
                                    pm := i.matchRequestedOrDefault(platforms.OnlyStrict, platform)
                                
                                    anyMissing := false
                                
                                
                                Severity: Major
                                Found in daemon/containerd/image_push.go - About 1 hr to fix

                                  Function initClusterSpec has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func initClusterSpec(node *swarmnode.Node, spec types.Spec) error {
                                      ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
                                      defer cancel()
                                      for conn := range node.ListenControlSocket(ctx) {
                                          if ctx.Err() != nil {
                                  Severity: Minor
                                  Found in daemon/cluster/swarm.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language