docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

Method Reconciler.ReconcileService has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
Open

func (r *Reconciler) ReconcileService(id string) error {
    var (
        service *api.Service
        tasks   []*api.Task
        cluster *api.Cluster
Severity: Minor
Found in manager/orchestrator/jobs/replicated/reconciler.go - About 5 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.Tasks has a Cognitive Complexity of 49 (exceeds 20 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: Minor
Found in manager/dispatcher/dispatcher.go - About 5 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 Meta.Unmarshal has 152 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

    Method IssueNodeCertificateRequest.Unmarshal has 151 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

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

      Method Endpoint.Unmarshal has 151 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

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

        Method ConfigSpec.Unmarshal has 150 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          Method ContainerSpec.Size has 150 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (m *ContainerSpec) Size() (n int) {
              if m == nil {
                  return 0
              }
              var l int
          Severity: Major
          Found in api/specs.pb.go - About 5 hrs to fix

            Method Updater.Run has 149 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (u *Updater) Run(ctx context.Context, slots []orchestrator.Slot) {
                defer close(u.doneChan)
            
                service := u.newService
            
            
            Severity: Major
            Found in manager/orchestrator/update/updater.go - About 4 hrs to fix

              Method Dispatcher.Assignments has 148 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (d *Dispatcher) Assignments(r *api.AssignmentsRequest, stream api.Dispatcher_AssignmentsServer) error {
                  d.rpcRW.RLock()
                  defer d.rpcRW.RUnlock()
              
                  dctx, err := d.isRunningLocked()
              Severity: Major
              Found in manager/dispatcher/dispatcher.go - About 4 hrs to fix

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

                func (g *Orchestrator) reconcileServices(ctx context.Context, serviceIDs []string) {
                    nodeTasks := make(map[string]map[string][]*api.Task)
                
                    g.store.View(func(tx store.ReadTx) {
                        for _, serviceID := range serviceIDs {
                Severity: Minor
                Found in manager/orchestrator/global/global.go - About 4 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 Config.Unmarshal has 145 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

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

                  Method StoreSnapshot.MarshalToSizedBuffer has 145 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

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

                    Method HealthCheckResponse.Unmarshal has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (m *HealthCheckResponse) Unmarshal(dAtA []byte) error {
                        l := len(dAtA)
                        iNdEx := 0
                        for iNdEx < l {
                            preIndex := iNdEx
                    Severity: Minor
                    Found in api/health.pb.go - About 4 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 ResolveAddressRequest.Unmarshal has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (m *ResolveAddressRequest) Unmarshal(dAtA []byte) error {
                        l := len(dAtA)
                        iNdEx := 0
                        for iNdEx < l {
                            preIndex := iNdEx
                    Severity: Minor
                    Found in api/raft.pb.go - About 4 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 ReplicatedService.Unmarshal has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (m *ReplicatedService) Unmarshal(dAtA []byte) error {
                        l := len(dAtA)
                        iNdEx := 0
                        for iNdEx < l {
                            preIndex := iNdEx
                    Severity: Minor
                    Found in api/specs.pb.go - About 4 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 LogSelector.Unmarshal has 143 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

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

                      Method LogContext.Unmarshal has 143 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

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

                        Method ContainerSpec_DNSConfig.Unmarshal has 143 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

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

                          Method SelectByCustom.Unmarshal has 143 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

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

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

                            func (p *raftProxyNodeCAServer) IssueNodeCertificate(ctx context.Context, r *IssueNodeCertificateRequest) (*IssueNodeCertificateResponse, error) {
                            
                                conn, err := p.connSelector.LeaderConn(ctx)
                                if err != nil {
                                    if err == raftselector.ErrIsLeader {
                            Severity: Major
                            Found in api/ca.pb.go and 13 other locations - About 4 hrs to fix
                            api/ca.pb.go on lines 1160..1193
                            api/ca.pb.go on lines 1195..1228
                            api/ca.pb.go on lines 1337..1370
                            api/dispatcher.pb.go on lines 2566..2599
                            api/dispatcher.pb.go on lines 2601..2634
                            api/dispatcher.pb.go on lines 2636..2669
                            api/health.pb.go on lines 444..477
                            api/raft.pb.go on lines 2158..2191
                            api/raft.pb.go on lines 2250..2283
                            api/raft.pb.go on lines 2357..2390
                            api/raft.pb.go on lines 2392..2425
                            api/resource.pb.go on lines 636..669
                            api/resource.pb.go on lines 671..704

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

                            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