docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

Method LogAttr.Unmarshal has 111 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (m *LogAttr) 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 Allocator.doNetworkAlloc has 111 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (a *Allocator) doNetworkAlloc(ctx context.Context, ev events.Event) {
        nc := a.netCtx
    
        switch v := ev.(type) {
        case api.EventCreateNetwork:
    Severity: Major
    Found in manager/allocator/network.go - About 3 hrs to fix

      Method LogMessage.Unmarshal has 39 return statements (exceeds 4 allowed).
      Open

      func (m *LogMessage) 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 Scheduler.Run has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
        Open

        func (s *Scheduler) Run(pctx context.Context) error {
            ctx := log.WithModule(pctx, "scheduler")
            defer close(s.doneChan)
        
            s.pipeline.AddFilter(&VolumesFilter{vs: s.volumes})
        Severity: Minor
        Found in manager/scheduler/scheduler.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 testSuite.TestNoDuplicateIPs has 109 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          Object has 28 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type Object struct {
              // Types that are valid to be assigned to Object:
              //    *Object_Node
              //    *Object_Service
              //    *Object_Network
          Severity: Minor
          Found in api/watch.pb.go - About 3 hrs to fix

            StoreAction has 28 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type StoreAction struct {
                Action StoreActionKind `protobuf:"varint,1,opt,name=action,proto3,enum=docker.swarmkit.v1.StoreActionKind" json:"action,omitempty"`
                // Types that are valid to be assigned to Target:
                //    *StoreAction_Node
                //    *StoreAction_Service
            Severity: Minor
            Found in api/raft.pb.go - About 3 hrs to fix

              Function ConvertTaskWatch has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
              Open

              func ConvertTaskWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
                  var (
                      m               Task
                      checkFuncs      []TaskCheckFunc
                      hasDesiredState bool
              Severity: Minor
              Found in api/objects.pb.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 Assignment.Unmarshal has 37 return statements (exceeds 4 allowed).
              Open

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

                Method Server.ListTasks has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
                Open

                func (s *Server) ListTasks(ctx context.Context, request *api.ListTasksRequest) (*api.ListTasksResponse, error) {
                    var (
                        tasks []*api.Task
                        err   error
                    )
                Severity: Minor
                Found in manager/controlapi/task.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 Dispatcher.Run has 106 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (d *Dispatcher) Run(ctx context.Context) error {
                    ctx = log.WithModule(ctx, "dispatcher")
                    log.G(ctx).Info("dispatcher starting")
                
                    d.taskUpdatesLock.Lock()
                Severity: Major
                Found in manager/dispatcher/dispatcher.go - About 3 hrs to fix

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

                  func (c *Collector) handleTaskEvent(event events.Event) {
                      var prevTask, newTask *api.Task
                  
                      switch v := event.(type) {
                      case api.EventCreateTask:
                  Severity: Major
                  Found in manager/metrics/collector.go and 1 other location - About 3 hrs to fix
                  manager/metrics/collector.go on lines 168..191

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

                  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 (c *Collector) handleNodeEvent(event events.Event) {
                      var prevNode, newNode *api.Node
                  
                      switch v := event.(type) {
                      case api.EventCreateNode:
                  Severity: Major
                  Found in manager/metrics/collector.go and 1 other location - About 3 hrs to fix
                  manager/metrics/collector.go on lines 193..220

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

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

                  func (m *SecretSpec) 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 Dispatcher.Tasks has 104 lines of code (exceeds 50 allowed). Consider refactoring.
                    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 3 hrs to fix

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

                      func changeNodeAvailability(cmd *cobra.Command, args []string, availability api.NodeSpec_Availability) error {
                          if len(args) == 0 {
                              return errors.New("missing node ID")
                          }
                      
                      
                      Severity: Major
                      Found in swarmd/cmd/swarmctl/node/common.go and 1 other location - About 3 hrs to fix
                      swarmd/cmd/swarmctl/node/common.go on lines 54..86

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

                      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 changeNodeRole(cmd *cobra.Command, args []string, role api.NodeRole) error {
                          if len(args) == 0 {
                              return errors.New("missing node ID")
                          }
                      
                      
                      Severity: Major
                      Found in swarmd/cmd/swarmctl/node/common.go and 1 other location - About 3 hrs to fix
                      swarmd/cmd/swarmctl/node/common.go on lines 20..52

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

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

                      func reconcileTaskState(ctx context.Context, w *worker, assignments []*api.AssignmentChange, fullSnapshot bool) error {
                          var (
                              updatedTasks []*api.Task
                              removedTasks []*api.Task
                          )
                      Severity: Major
                      Found in agent/worker.go - About 3 hrs to fix

                        Function WatchMessageEvent has 103 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func WatchMessageEvent(c Event) *WatchMessage_Event {
                            switch v := c.(type) {
                            case EventCreateNode:
                                return &WatchMessage_Event{Action: WatchActionKindCreate, Object: &Object{Object: &Object_Node{Node: v.Node}}}
                            case EventUpdateNode:
                        Severity: Major
                        Found in api/objects.pb.go - About 3 hrs to fix

                          Method Scheduler.applySchedulingDecisions has 103 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (s *Scheduler) applySchedulingDecisions(ctx context.Context, schedulingDecisions map[string]schedulingDecision) (successful, failed []schedulingDecision) {
                              // applySchedulingDecisions is the only place where we make store
                              // transactions in the scheduler. the scheduler is responsible for freeing
                              // volumes that are no longer in use. this means that volumes should be
                              // freed in this function. sometimes, there are no scheduling decisions to
                          Severity: Major
                          Found in manager/scheduler/scheduler.go - About 3 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language