docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

Method Server.RemoveNode has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s *Server) RemoveNode(ctx context.Context, request *api.RemoveNodeRequest) (*api.RemoveNodeResponse, error) {
    if request.NodeID == "" {
        return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
    }

Severity: Minor
Found in manager/controlapi/node.go - About 1 hr to fix

    Method Dispatcher.UpdateTaskStatus has 57 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (d *Dispatcher) UpdateTaskStatus(ctx context.Context, r *api.UpdateTaskStatusRequest) (*api.UpdateTaskStatusResponse, error) {
        d.rpcRW.RLock()
        defer d.rpcRW.RUnlock()
    
        dctx, err := d.isRunningLocked()
    Severity: Minor
    Found in manager/dispatcher/dispatcher.go - About 1 hr to fix

      Function WatchFrom has 57 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func WatchFrom(store *MemoryStore, version *api.Version, specifiers ...api.Event) (chan events.Event, func(), error) {
          if version == nil {
              ch, cancel := state.Watch(store.WatchQueue(), specifiers...)
              return ch, cancel, nil
          }
      Severity: Minor
      Found in manager/state/store/memory.go - About 1 hr to fix

        Function init has 57 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func init() {
            register(ObjectStoreConfig{
                Table: &memdb.TableSchema{
                    Name: tableNode,
                    Indexes: map[string]*memdb.IndexSchema{
        Severity: Minor
        Found in manager/state/store/nodes.go - About 1 hr to fix

          Function init has 57 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func init() {
              register(ObjectStoreConfig{
                  Table: &memdb.TableSchema{
                      Name: tableVolume,
                      Indexes: map[string]*memdb.IndexSchema{
          Severity: Minor
          Found in manager/state/store/volumes.go - About 1 hr to fix

            Method Allocator.doNetworkInit has 57 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (a *Allocator) doNetworkInit(ctx context.Context) (err error) {
                nc := &networkContext{
                    nwkAllocator:        a.nwkAllocator,
                    portAllocator:       newPortAllocator(),
                    pendingTasks:        make(map[string]*api.Task),
            Severity: Minor
            Found in manager/allocator/network.go - About 1 hr to fix

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

              func (g *Orchestrator) deleteTask(ctx context.Context, batch *store.Batch, t *api.Task) {
                  err := batch.Update(func(tx store.Tx) error {
                      return store.DeleteTask(tx, t.ID)
                  })
                  if err != nil {
              Severity: Major
              Found in manager/orchestrator/global/global.go and 1 other location - About 1 hr to fix
              manager/orchestrator/replicated/services.go on lines 251..258

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

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

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

              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 (r *Orchestrator) deleteTask(ctx context.Context, batch *store.Batch, t *api.Task) {
                  err := batch.Update(func(tx store.Tx) error {
                      return store.DeleteTask(tx, t.ID)
                  })
                  if err != nil {
              Severity: Major
              Found in manager/orchestrator/replicated/services.go and 1 other location - About 1 hr to fix
              manager/orchestrator/global/global.go on lines 568..575

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

              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 *LogAttr) 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/objects.pb.go on lines 2763..2778

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

              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 processIPAMOptions has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
              Open

              func processIPAMOptions(cmd *cobra.Command) (*api.IPAMOptions, error) {
                  flags := cmd.Flags()
              
                  var ipamOpts *api.IPAMOptions
                  if flags.Changed("ipam-driver") {
              Severity: Minor
              Found in swarmd/cmd/swarmctl/network/create.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 Task.MarshalToSizedBuffer has 13 return statements (exceeds 4 allowed).
              Open

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

                Method NetworkSpec.MarshalToSizedBuffer has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func (m *NetworkSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                    i := len(dAtA)
                    _ = i
                    var l int
                    _ = l
                Severity: Minor
                Found in api/specs.pb.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 Supervisor.Restart has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func (r *Supervisor) Restart(ctx context.Context, tx store.Tx, cluster *api.Cluster, service *api.Service, t api.Task) error {
                    // TODO(aluzzardi): This function should not depend on `service`.
                
                    // Is the old task still in the process of restarting? If so, wait for
                    // its restart delay to elapse, to avoid tight restart loops (for
                Severity: Minor
                Found in manager/orchestrator/restart/restart.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 Orchestrator.tickTasks has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func (g *Orchestrator) tickTasks(ctx context.Context) {
                    if len(g.restartTasks) == 0 {
                        return
                    }
                    err := g.store.Batch(func(batch *store.Batch) error {
                Severity: Minor
                Found in manager/orchestrator/global/global.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

                Function validateHealthCheck has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func validateHealthCheck(hc *api.HealthConfig) error {
                    if hc == nil {
                        return nil
                    }
                
                
                Severity: Minor
                Found in manager/controlapi/service.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 LogBroker.PublishLogs has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                Open

                func (lb *LogBroker) PublishLogs(stream api.LogBroker_PublishLogsServer) (err error) {
                    remote, err := ca.RemoteNode(stream.Context())
                    if err != nil {
                        return err
                    }
                Severity: Minor
                Found in manager/logbroker/broker.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

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

                func (m *UpdateTaskStatusRequest) CopyFrom(src interface{}) {
                
                    o := src.(*UpdateTaskStatusRequest)
                    *m = *o
                    if o.Updates != nil {
                Severity: Major
                Found in api/dispatcher.pb.go and 5 other locations - About 1 hr to fix
                api/dispatcher.pb.go on lines 1151..1163
                api/dispatcher.pb.go on lines 1214..1226
                api/dispatcher.pb.go on lines 1315..1327
                api/specs.pb.go on lines 2037..2049
                api/watch.pb.go on lines 1153..1165

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

                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 (m *UpdateVolumeStatusRequest) CopyFrom(src interface{}) {
                
                    o := src.(*UpdateVolumeStatusRequest)
                    *m = *o
                    if o.Updates != nil {
                Severity: Major
                Found in api/dispatcher.pb.go and 5 other locations - About 1 hr to fix
                api/dispatcher.pb.go on lines 1099..1111
                api/dispatcher.pb.go on lines 1214..1226
                api/dispatcher.pb.go on lines 1315..1327
                api/specs.pb.go on lines 2037..2049
                api/watch.pb.go on lines 1153..1165

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

                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 (m *AssignmentsMessage) CopyFrom(src interface{}) {
                
                    o := src.(*AssignmentsMessage)
                    *m = *o
                    if o.Changes != nil {
                Severity: Major
                Found in api/dispatcher.pb.go and 5 other locations - About 1 hr to fix
                api/dispatcher.pb.go on lines 1099..1111
                api/dispatcher.pb.go on lines 1151..1163
                api/dispatcher.pb.go on lines 1214..1226
                api/specs.pb.go on lines 2037..2049
                api/watch.pb.go on lines 1153..1165

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

                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