docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

Method TaskSpec.MarshalToSizedBuffer has 95 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (m *TaskSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
    i := len(dAtA)
    _ = i
    var l int
    _ = l
Severity: Major
Found in api/specs.pb.go - About 2 hrs to fix

    Method testSuite.TestServiceAddRemovePorts has 95 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

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

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

      func (s *Server) checkConfigExistence(tx store.Tx, spec *api.ServiceSpec) error {
          container := spec.Task.GetContainer()
          if container == nil {
              return nil
          }
      Severity: Major
      Found in manager/controlapi/service.go and 1 other location - About 2 hrs to fix
      manager/controlapi/service.go on lines 665..691

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

      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 (s *Server) checkSecretExistence(tx store.Tx, spec *api.ServiceSpec) error {
          container := spec.Task.GetContainer()
          if container == nil {
              return nil
          }
      Severity: Major
      Found in manager/controlapi/service.go and 1 other location - About 2 hrs to fix
      manager/controlapi/service.go on lines 694..720

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

      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

      File testutils.go has 533 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package testutils
      
      import (
          "context"
          "net"
      Severity: Minor
      Found in manager/state/raft/testutils/testutils.go - About 2 hrs to fix

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

                case 1:
                    if wireType != 2 {
                        return fmt.Errorf("proto: wrong wireType = %d for field UnlockKey", wireType)
                    }
                    var byteLen int
        Severity: Major
        Found in api/ca.pb.go and 6 other locations - About 2 hrs to fix
        api/ca.pb.go on lines 1837..1870
        api/ca.pb.go on lines 2123..2156
        api/dispatcher.pb.go on lines 3617..3650
        api/logbroker.pb.go on lines 3104..3137
        api/specs.pb.go on lines 8629..8662
        api/specs.pb.go on lines 8818..8851

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

        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 7 locations. Consider refactoring.
        Open

                case 2:
                    if wireType != 2 {
                        return fmt.Errorf("proto: wrong wireType = %d for field CSR", wireType)
                    }
                    var byteLen int
        Severity: Major
        Found in api/ca.pb.go and 6 other locations - About 2 hrs to fix
        api/ca.pb.go on lines 2123..2156
        api/ca.pb.go on lines 2257..2290
        api/dispatcher.pb.go on lines 3617..3650
        api/logbroker.pb.go on lines 3104..3137
        api/specs.pb.go on lines 8629..8662
        api/specs.pb.go on lines 8818..8851

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

        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 7 locations. Consider refactoring.
        Open

                case 2:
                    if wireType != 2 {
                        return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
                    }
                    var byteLen int
        Severity: Major
        Found in api/specs.pb.go and 6 other locations - About 2 hrs to fix
        api/ca.pb.go on lines 1837..1870
        api/ca.pb.go on lines 2123..2156
        api/ca.pb.go on lines 2257..2290
        api/dispatcher.pb.go on lines 3617..3650
        api/logbroker.pb.go on lines 3104..3137
        api/specs.pb.go on lines 8818..8851

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

        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 7 locations. Consider refactoring.
        Open

                case 5:
                    if wireType != 2 {
                        return fmt.Errorf("proto: wrong wireType = %d for field RootCA", wireType)
                    }
                    var byteLen int
        Severity: Major
        Found in api/dispatcher.pb.go and 6 other locations - About 2 hrs to fix
        api/ca.pb.go on lines 1837..1870
        api/ca.pb.go on lines 2123..2156
        api/ca.pb.go on lines 2257..2290
        api/logbroker.pb.go on lines 3104..3137
        api/specs.pb.go on lines 8629..8662
        api/specs.pb.go on lines 8818..8851

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

        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 7 locations. Consider refactoring.
        Open

                case 4:
                    if wireType != 2 {
                        return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
                    }
                    var byteLen int
        Severity: Major
        Found in api/logbroker.pb.go and 6 other locations - About 2 hrs to fix
        api/ca.pb.go on lines 1837..1870
        api/ca.pb.go on lines 2123..2156
        api/ca.pb.go on lines 2257..2290
        api/dispatcher.pb.go on lines 3617..3650
        api/specs.pb.go on lines 8629..8662
        api/specs.pb.go on lines 8818..8851

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

        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 7 locations. Consider refactoring.
        Open

                case 2:
                    if wireType != 2 {
                        return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
                    }
                    var byteLen int
        Severity: Major
        Found in api/specs.pb.go and 6 other locations - About 2 hrs to fix
        api/ca.pb.go on lines 1837..1870
        api/ca.pb.go on lines 2123..2156
        api/ca.pb.go on lines 2257..2290
        api/dispatcher.pb.go on lines 3617..3650
        api/logbroker.pb.go on lines 3104..3137
        api/specs.pb.go on lines 8629..8662

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

        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 7 locations. Consider refactoring.
        Open

                case 1:
                    if wireType != 2 {
                        return fmt.Errorf("proto: wrong wireType = %d for field Certificate", wireType)
                    }
                    var byteLen int
        Severity: Major
        Found in api/ca.pb.go and 6 other locations - About 2 hrs to fix
        api/ca.pb.go on lines 1837..1870
        api/ca.pb.go on lines 2257..2290
        api/dispatcher.pb.go on lines 3617..3650
        api/logbroker.pb.go on lines 3104..3137
        api/specs.pb.go on lines 8629..8662
        api/specs.pb.go on lines 8818..8851

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

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

        func (ce *ConstraintEnforcer) rejectNoncompliantTasks(node *api.Node) {
            // If the availability is "drain", the orchestrator will
            // shut down all tasks.
            // If the availability is "pause", we shouldn't touch
            // the tasks on this node.
        Severity: Major
        Found in manager/orchestrator/constraintenforcer/constraint_enforcer.go - About 2 hrs to fix

          Method AssignmentsMessage.Unmarshal has 31 return statements (exceeds 4 allowed).
          Open

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

            Method RaftMember.Unmarshal has 31 return statements (exceeds 4 allowed).
            Open

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

              Method Updater.worker has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
              Open

              func (u *Updater) worker(ctx context.Context, queue <-chan orchestrator.Slot, updateConfig *api.UpdateConfig) {
                  for slot := range queue {
                      // Do we have a task with the new spec in desired state = RUNNING?
                      // If so, all we have to do to complete the update is remove the
                      // other tasks. Or if we have a task with the new spec that has
              Severity: Minor
              Found in manager/orchestrator/update/updater.go - About 2 hrs 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 TLSRenewer.Start has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
              Open

              func (t *TLSRenewer) Start(ctx context.Context) <-chan CertificateUpdate {
                  updates := make(chan CertificateUpdate)
              
                  go func() {
                      var (
              Severity: Minor
              Found in ca/renewer.go - About 2 hrs 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 validateCAConfig has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
              Open

              func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cluster *api.Cluster) (*api.RootCA, error) {
                  newConfig := cluster.Spec.CAConfig.Copy()
                  newConfig.SigningCACert = ca.NormalizePEMs(newConfig.SigningCACert) // ensure this is normalized before we use it
              
                  if len(newConfig.SigningCAKey) > 0 && len(newConfig.SigningCACert) == 0 {
              Severity: Minor
              Found in manager/controlapi/ca_rotation.go - About 2 hrs 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 roleManager.Run has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
              Open

              func (rm *roleManager) Run(ctx context.Context) {
                  defer close(rm.doneChan)
              
                  var (
                      nodes []*api.Node
              Severity: Minor
              Found in manager/role_manager.go - About 2 hrs 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 ContainerSpec.CopyFrom has 93 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (m *ContainerSpec) CopyFrom(src interface{}) {
              
                  o := src.(*ContainerSpec)
                  *m = *o
                  if o.Labels != nil {
              Severity: Major
              Found in api/specs.pb.go - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language