docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

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

func (*Object) XXX_OneofWrappers() []interface{} {
    return []interface{}{
        (*Object_Node)(nil),
        (*Object_Service)(nil),
        (*Object_Network)(nil),
Severity: Major
Found in api/watch.pb.go and 1 other location - About 1 hr to fix
api/raft.pb.go on lines 697..710

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

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 FindNodes(tx ReadTx, by By) ([]*api.Node, error) {
    checkType := func(by By) error {
        switch by.(type) {
        case byName, byNamePrefix, byIDPrefix, byRole, byMembership, byCustom, byCustomPrefix:
            return nil
Severity: Major
Found in manager/state/store/nodes.go and 1 other location - About 1 hr to fix
manager/state/store/volumes.go on lines 103..120

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

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 FindVolumes(tx ReadTx, by By) ([]*api.Volume, error) {
    checkType := func(by By) error {
        switch by.(type) {
        case byName, byNamePrefix, byIDPrefix, byVolumeGroup, byCustom, byCustomPrefix, byDriver:
            return nil
Severity: Major
Found in manager/state/store/volumes.go and 1 other location - About 1 hr to fix
manager/state/store/nodes.go on lines 103..120

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

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 (*StoreAction) XXX_OneofWrappers() []interface{} {
    return []interface{}{
        (*StoreAction_Node)(nil),
        (*StoreAction_Service)(nil),
        (*StoreAction_Task)(nil),
Severity: Major
Found in api/raft.pb.go and 1 other location - About 1 hr to fix
api/watch.pb.go on lines 245..258

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

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

Function renewCerts has 10 return statements (exceeds 4 allowed).
Open

func renewCerts(swarmdir, unlockKey string) error {
    // First, load the existing cert.  We don't actually bother to check if
    // it's expired - this will just obtain a new cert anyway.
    krw, err := getKRW(swarmdir, unlockKey)
    if err != nil {
Severity: Major
Found in swarmd/cmd/swarm-rafttool/renewcert.go - About 1 hr to fix

    Function parseContainer has 10 return statements (exceeds 4 allowed).
    Open

    func parseContainer(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
        if flags.Changed("image") {
            image, err := flags.GetString("image")
            if err != nil {
                return err
    Severity: Major
    Found in swarmd/cmd/swarmctl/service/flagparser/container.go - About 1 hr to fix

      Method controller.Wait has 10 return statements (exceeds 4 allowed).
      Open

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

        Function ConvertNodeWatch has 10 return statements (exceeds 4 allowed).
        Open

        func ConvertNodeWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
            var (
                m             Node
                checkFuncs    []NodeCheckFunc
                hasRole       bool
        Severity: Major
        Found in api/objects.pb.go - About 1 hr to fix

          Method Server.IssueNodeCertificate has 10 return statements (exceeds 4 allowed).
          Open

          func (s *Server) IssueNodeCertificate(ctx context.Context, request *api.IssueNodeCertificateRequest) (*api.IssueNodeCertificateResponse, error) {
              // First, let's see if the remote node is presenting a non-empty CSR
              if len(request.CSR) == 0 {
                  return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
              }
          Severity: Major
          Found in ca/server.go - About 1 hr to fix

            Method Supervisor.shouldRestart has 10 return statements (exceeds 4 allowed).
            Open

            func (r *Supervisor) shouldRestart(ctx context.Context, t *api.Task, service *api.Service) bool {
                // TODO(aluzzardi): This function should not depend on `service`.
                // There are 3 possible restart policies.
                switch orchestrator.RestartCondition(t) {
                case api.RestartOnAny:
            Severity: Major
            Found in manager/orchestrator/restart/restart.go - About 1 hr to fix

              Method Server.UpdateNode has 10 return statements (exceeds 4 allowed).
              Open

              func (s *Server) UpdateNode(ctx context.Context, request *api.UpdateNodeRequest) (*api.UpdateNodeResponse, error) {
                  if request.NodeID == "" || request.NodeVersion == nil {
                      return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
                  }
                  if err := validateNodeSpec(request.Spec); err != nil {
              Severity: Major
              Found in manager/controlapi/node.go - About 1 hr to fix

                Method Dispatcher.Tasks has 10 return statements (exceeds 4 allowed).
                Open

                func (d *Dispatcher) Tasks(r *api.TasksRequest, stream api.Dispatcher_TasksServer) error {
                    d.rpcRW.RLock()
                    defer d.rpcRW.RUnlock()
                
                    dctx, err := d.isRunningLocked()
                Severity: Major
                Found in manager/dispatcher/dispatcher.go - About 1 hr to fix

                  Method testSuite.TestNodeAllocator has 10 return statements (exceeds 4 allowed).
                  Open

                  func (suite *testSuite) TestNodeAllocator() {
                      s := store.NewMemoryStore(nil)
                      suite.NotNil(s)
                      defer s.Close()
                  
                  
                  Severity: Major
                  Found in manager/allocator/allocator_test_suite.go - About 1 hr to fix

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

                    func (sa *StubAPIClient) called() {
                        pc, _, _, ok := runtime.Caller(1)
                        if !ok {
                            panic("failed to update counts")
                        }
                    Severity: Major
                    Found in swarmd/dockerexec/docker_client_stub.go and 1 other location - About 1 hr to fix
                    agent/exec/controller_stub.go on lines 35..45

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

                    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 (m *InternalRaftRequest) CopyFrom(src interface{}) {
                    
                        o := src.(*InternalRaftRequest)
                        *m = *o
                        if o.Action != nil {
                    Severity: Major
                    Found in api/raft.pb.go and 2 other locations - About 1 hr to fix
                    api/logbroker.pb.go on lines 816..827
                    api/logbroker.pb.go on lines 871..882

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

                    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 (m *PublishLogsMessage) CopyFrom(src interface{}) {
                    
                        o := src.(*PublishLogsMessage)
                        *m = *o
                        if o.Messages != nil {
                    Severity: Major
                    Found in api/logbroker.pb.go and 2 other locations - About 1 hr to fix
                    api/logbroker.pb.go on lines 816..827
                    api/raft.pb.go on lines 1014..1025

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

                    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

                        err := a.store.Batch(func(batch *store.Batch) error {
                            for _, s := range allocatedServices {
                                if err := a.commitAllocatedService(ctx, batch, s); err != nil {
                                    log.G(ctx).WithError(err).Debugf("Failed to commit allocation of unallocated service %s", s.ID)
                                    continue
                    Severity: Major
                    Found in manager/allocator/network.go and 1 other location - About 1 hr to fix
                    manager/allocator/network.go on lines 1415..1424

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

                    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

                        err := a.store.Batch(func(batch *store.Batch) error {
                            for _, n := range allocatedNetworks {
                                if err := a.commitAllocatedNetwork(ctx, batch, n); err != nil {
                                    log.G(ctx).WithError(err).Debugf("Failed to commit allocation of unallocated network %s", n.ID)
                                    continue
                    Severity: Major
                    Found in manager/allocator/network.go and 1 other location - About 1 hr to fix
                    manager/allocator/network.go on lines 1454..1463

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

                    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 (m *SubscribeLogsMessage) CopyFrom(src interface{}) {
                    
                        o := src.(*SubscribeLogsMessage)
                        *m = *o
                        if o.Messages != nil {
                    Severity: Major
                    Found in api/logbroker.pb.go and 2 other locations - About 1 hr to fix
                    api/logbroker.pb.go on lines 871..882
                    api/raft.pb.go on lines 1014..1025

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

                    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 (sc *StubController) called() {
                        pc, _, _, ok := runtime.Caller(1)
                        if !ok {
                            panic("Failed to find caller of function")
                        }
                    Severity: Major
                    Found in agent/exec/controller_stub.go and 1 other location - About 1 hr to fix
                    swarmd/dockerexec/docker_client_stub.go on lines 41..51

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

                    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