docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

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

func (m *DetachNetworkRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
    i := len(dAtA)
    _ = i
    var l int
    _ = l
Severity: Major
Found in api/resource.pb.go and 10 other locations - About 1 hr to fix
api/ca.pb.go on lines 816..829
api/ca.pb.go on lines 998..1011
api/dispatcher.pb.go on lines 1860..1873
api/dispatcher.pb.go on lines 2137..2150
api/dispatcher.pb.go on lines 2204..2217
api/health.pb.go on lines 317..330
api/raft.pb.go on lines 1489..1502
api/raft.pb.go on lines 1770..1783
api/resource.pb.go on lines 484..497
api/specs.pb.go on lines 2809..2822

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

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 Server.NodeCertificateStatus has 62 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCertificateStatusRequest) (*api.NodeCertificateStatusResponse, error) {
    if request.NodeID == "" {
        return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
    }

Severity: Minor
Found in ca/server.go - About 1 hr to fix

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

    func (m *NodeCertificateStatusResponse) Size() (n int) {
        if m == nil {
            return 0
        }
        var l int
    Severity: Major
    Found in api/ca.pb.go and 1 other location - About 1 hr to fix
    api/logbroker.pb.go on lines 2136..2151

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

    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 (m *SubscribeLogsRequest) Size() (n int) {
        if m == nil {
            return 0
        }
        var l int
    Severity: Major
    Found in api/logbroker.pb.go and 1 other location - About 1 hr to fix
    api/ca.pb.go on lines 1385..1400

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

    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 (m *InternalRaftRequest) Size() (n int) {
        if m == nil {
            return 0
        }
        var l int
    Severity: Major
    Found in api/raft.pb.go and 1 other location - About 1 hr to fix
    api/specs.pb.go on lines 4291..4307

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

    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 (m *EndpointSpec) Size() (n int) {
        if m == nil {
            return 0
        }
        var l int
    Severity: Major
    Found in api/specs.pb.go and 1 other location - About 1 hr to fix
    api/raft.pb.go on lines 2576..2592

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

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

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

      Method Orchestrator.reconcile has 61 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (r *Orchestrator) reconcile(ctx context.Context, service *api.Service) {
          runningSlots, deadSlots, err := r.updatableAndDeadSlots(ctx, service)
          if err != nil {
              log.G(ctx).WithError(err).Errorf("reconcile failed finding tasks")
              return
      Severity: Minor
      Found in manager/orchestrator/replicated/services.go - About 1 hr to fix

        Method assignmentSet.releaseTaskDependencies has 61 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (a *assignmentSet) releaseTaskDependencies(readTx store.ReadTx, t *api.Task) bool {
            var modified bool
        
            for _, resourceRef := range t.Spec.ResourceReferences {
                var assignment *api.Assignment
        Severity: Minor
        Found in manager/dispatcher/assignments.go - About 1 hr to fix

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

          func GetTaskStatus(tx *bolt.Tx, id string) (*api.TaskStatus, error) {
              var ts api.TaskStatus
              if err := withTaskBucket(tx, id, func(bkt *bolt.Bucket) error {
                  p := bkt.Get(bucketKeyStatus)
                  if p == nil {
          Severity: Major
          Found in agent/storage.go and 1 other location - About 1 hr to fix
          agent/storage.go on lines 34..49

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

          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 GetTask(tx *bolt.Tx, id string) (*api.Task, error) {
              var t api.Task
          
              if err := withTaskBucket(tx, id, func(bkt *bolt.Bucket) error {
                  p := bkt.Get(bucketKeyData)
          Severity: Major
          Found in agent/storage.go and 1 other location - About 1 hr to fix
          agent/storage.go on lines 82..96

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

          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 HealthCheckRequest.Unmarshal has 15 return statements (exceeds 4 allowed).
          Open

          func (m *HealthCheckRequest) Unmarshal(dAtA []byte) error {
              l := len(dAtA)
              iNdEx := 0
              for iNdEx < l {
                  preIndex := iNdEx
          Severity: Major
          Found in api/health.pb.go - About 1 hr to fix

            Function parseContainer has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
            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: Minor
            Found in swarmd/cmd/swarmctl/service/flagparser/container.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 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 swarmd/dockerexec/controller.go - About 1 hr to fix

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

              func (m *NodeCertificateStatusRequest) Unmarshal(dAtA []byte) error {
                  l := len(dAtA)
                  iNdEx := 0
                  for iNdEx < l {
                      preIndex := iNdEx
              Severity: Major
              Found in api/ca.pb.go - About 1 hr to fix

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

                func (m *GetRootCACertificateResponse) Unmarshal(dAtA []byte) error {
                    l := len(dAtA)
                    iNdEx := 0
                    for iNdEx < l {
                        preIndex := iNdEx
                Severity: Major
                Found in api/ca.pb.go - About 1 hr to fix

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

                  func (m *DetachNetworkRequest) Unmarshal(dAtA []byte) error {
                      l := len(dAtA)
                      iNdEx := 0
                      for iNdEx < l {
                          preIndex := iNdEx
                  Severity: Major
                  Found in api/resource.pb.go - About 1 hr to fix

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

                    func (m *AttachNetworkResponse) Unmarshal(dAtA []byte) error {
                        l := len(dAtA)
                        iNdEx := 0
                        for iNdEx < l {
                            preIndex := iNdEx
                    Severity: Major
                    Found in api/resource.pb.go - About 1 hr to fix

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

                      func (m *TasksRequest) Unmarshal(dAtA []byte) error {
                          l := len(dAtA)
                          iNdEx := 0
                          for iNdEx < l {
                              preIndex := iNdEx
                      Severity: Major
                      Found in api/dispatcher.pb.go - About 1 hr to fix

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

                        func (m *HeartbeatRequest) Unmarshal(dAtA []byte) error {
                            l := len(dAtA)
                            iNdEx := 0
                            for iNdEx < l {
                                preIndex := iNdEx
                        Severity: Major
                        Found in api/dispatcher.pb.go - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language