docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

Method testSuite.TestAllocatorRestartNoEndpointSpec has 124 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (suite *testSuite) TestAllocatorRestartNoEndpointSpec() {
    s := store.NewMemoryStore(nil)
    suite.NotNil(s)
    defer s.Close()
    // Create 3 services with 1 task each
Severity: Major
Found in manager/allocator/allocator_test_suite.go - About 3 hrs to fix

    Method Orchestrator.reconcileOneNode has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
    Open

    func (g *Orchestrator) reconcileOneNode(ctx context.Context, node *api.Node) {
        if node.Spec.Availability == api.NodeAvailabilityDrain {
            log.G(ctx).Debugf("global orchestrator: node %s in drain state, shutting down its tasks", node.ID)
            g.foreachTaskFromNode(ctx, node, g.shutdownTask)
            return
    Severity: Minor
    Found in manager/orchestrator/global/global.go - About 3 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 Server.checkPortConflicts has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
    Open

    func (s *Server) checkPortConflicts(spec *api.ServiceSpec, serviceID string) error {
        if spec.Endpoint == nil {
            return nil
        }
    
    
    Severity: Minor
    Found in manager/controlapi/service.go - About 3 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 readTx.findIterators has 45 return statements (exceeds 4 allowed).
    Open

    func (tx readTx) findIterators(table string, by By, checkType func(By) error) ([]memdb.ResultIterator, error) {
        switch by.(type) {
        case byAll, orCombinator: // generic types
        default: // all other types
            if err := checkType(by); err != nil {
    Severity: Major
    Found in manager/state/store/memory.go - About 3 hrs to fix

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

          if storeObject.WatchSelectors.Name != nil && *storeObject.WatchSelectors.Name {
              d.P("case *SelectBy_Name:")
              d.In()
              if *m.Name == "Node" {
                  d.P("if m.Description != nil {")
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 1 other location - About 3 hrs to fix
      protobuf/plugin/storeobject/storeobject.go on lines 427..455

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

      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

          if storeObject.WatchSelectors.NamePrefix != nil && *storeObject.WatchSelectors.NamePrefix {
              d.P("case *SelectBy_NamePrefix:")
              d.In()
              if *m.Name == "Node" {
                  d.P("if m.Description != nil {")
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 1 other location - About 3 hrs to fix
      protobuf/plugin/storeobject/storeobject.go on lines 398..426

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

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

      func (p *raftProxyLogsServer) SubscribeLogs(r *SubscribeLogsRequest, stream Logs_SubscribeLogsServer) error {
          ctx := stream.Context()
          conn, err := p.connSelector.LeaderConn(ctx)
          if err != nil {
              if err == raftselector.ErrIsLeader {
      Severity: Major
      Found in api/logbroker.pb.go and 5 other locations - About 3 hrs to fix
      api/dispatcher.pb.go on lines 2524..2564
      api/dispatcher.pb.go on lines 2680..2720
      api/dispatcher.pb.go on lines 2731..2771
      api/logbroker.pb.go on lines 1920..1960
      api/watch.pb.go on lines 2230..2270

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

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

      func (p *raftProxyDispatcherServer) Tasks(r *TasksRequest, stream Dispatcher_TasksServer) error {
          ctx := stream.Context()
          conn, err := p.connSelector.LeaderConn(ctx)
          if err != nil {
              if err == raftselector.ErrIsLeader {
      Severity: Major
      Found in api/dispatcher.pb.go and 5 other locations - About 3 hrs to fix
      api/dispatcher.pb.go on lines 2524..2564
      api/dispatcher.pb.go on lines 2731..2771
      api/logbroker.pb.go on lines 1797..1837
      api/logbroker.pb.go on lines 1920..1960
      api/watch.pb.go on lines 2230..2270

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

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

      func (p *raftProxyDispatcherServer) Assignments(r *AssignmentsRequest, stream Dispatcher_AssignmentsServer) error {
          ctx := stream.Context()
          conn, err := p.connSelector.LeaderConn(ctx)
          if err != nil {
              if err == raftselector.ErrIsLeader {
      Severity: Major
      Found in api/dispatcher.pb.go and 5 other locations - About 3 hrs to fix
      api/dispatcher.pb.go on lines 2524..2564
      api/dispatcher.pb.go on lines 2680..2720
      api/logbroker.pb.go on lines 1797..1837
      api/logbroker.pb.go on lines 1920..1960
      api/watch.pb.go on lines 2230..2270

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

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

      func (p *raftProxyLogBrokerServer) ListenSubscriptions(r *ListenSubscriptionsRequest, stream LogBroker_ListenSubscriptionsServer) error {
          ctx := stream.Context()
          conn, err := p.connSelector.LeaderConn(ctx)
          if err != nil {
              if err == raftselector.ErrIsLeader {
      Severity: Major
      Found in api/logbroker.pb.go and 5 other locations - About 3 hrs to fix
      api/dispatcher.pb.go on lines 2524..2564
      api/dispatcher.pb.go on lines 2680..2720
      api/dispatcher.pb.go on lines 2731..2771
      api/logbroker.pb.go on lines 1797..1837
      api/watch.pb.go on lines 2230..2270

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

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

      func (p *raftProxyDispatcherServer) Session(r *SessionRequest, stream Dispatcher_SessionServer) error {
          ctx := stream.Context()
          conn, err := p.connSelector.LeaderConn(ctx)
          if err != nil {
              if err == raftselector.ErrIsLeader {
      Severity: Major
      Found in api/dispatcher.pb.go and 5 other locations - About 3 hrs to fix
      api/dispatcher.pb.go on lines 2680..2720
      api/dispatcher.pb.go on lines 2731..2771
      api/logbroker.pb.go on lines 1797..1837
      api/logbroker.pb.go on lines 1920..1960
      api/watch.pb.go on lines 2230..2270

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

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

      func (p *raftProxyWatchServer) Watch(r *WatchRequest, stream Watch_WatchServer) error {
          ctx := stream.Context()
          conn, err := p.connSelector.LeaderConn(ctx)
          if err != nil {
              if err == raftselector.ErrIsLeader {
      Severity: Major
      Found in api/watch.pb.go and 5 other locations - About 3 hrs to fix
      api/dispatcher.pb.go on lines 2524..2564
      api/dispatcher.pb.go on lines 2680..2720
      api/dispatcher.pb.go on lines 2731..2771
      api/logbroker.pb.go on lines 1797..1837
      api/logbroker.pb.go on lines 1920..1960

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

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

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

        Function parseUpdate has 119 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func parseUpdate(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
            if flags.Changed("update-parallelism") {
                parallelism, err := flags.GetUint64("update-parallelism")
                if err != nil {
                    return err
        Severity: Major
        Found in swarmd/cmd/swarmctl/service/flagparser/update.go - About 3 hrs to fix

          Method SubscribeLogsRequest.Unmarshal has 119 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

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

            Method Dispatcher.Session has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
            Open

            func (d *Dispatcher) Session(r *api.SessionRequest, stream api.Dispatcher_SessionServer) error {
                d.rpcRW.RLock()
                defer d.rpcRW.RUnlock()
            
                dctx, err := d.isRunningLocked()
            Severity: Minor
            Found in manager/dispatcher/dispatcher.go - About 3 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_Ulimit.Unmarshal has 117 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

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

              Method WatchMessage.Unmarshal has 117 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

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

                Method Reconciler.ReconcileService has 117 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (r *Reconciler) ReconcileService(id string) error {
                    var (
                        service *api.Service
                        tasks   []*api.Task
                        cluster *api.Cluster
                Severity: Major
                Found in manager/orchestrator/jobs/replicated/reconciler.go - About 3 hrs to fix

                  Method SessionMessage.Unmarshal has 42 return statements (exceeds 4 allowed).
                  Open

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