docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

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

func (m *HealthCheckRequest) Unmarshal(dAtA []byte) error {
    l := len(dAtA)
    iNdEx := 0
    for iNdEx < l {
        preIndex := iNdEx
Severity: Major
Found in api/health.pb.go and 10 other locations - About 1 day to fix
api/ca.pb.go on lines 1585..1666
api/dispatcher.pb.go on lines 3672..3753
api/dispatcher.pb.go on lines 4389..4470
api/dispatcher.pb.go on lines 4555..4636
api/raft.pb.go on lines 3154..3235
api/raft.pb.go on lines 3892..3973
api/resource.pb.go on lines 930..1011
api/resource.pb.go on lines 1012..1093
api/specs.pb.go on lines 6296..6377
api/specs.pb.go on lines 7535..7616

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

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

func (m *NodeCertificateStatusRequest) Unmarshal(dAtA []byte) error {
    l := len(dAtA)
    iNdEx := 0
    for iNdEx < l {
        preIndex := iNdEx
Severity: Major
Found in api/ca.pb.go and 10 other locations - About 1 day to fix
api/dispatcher.pb.go on lines 3672..3753
api/dispatcher.pb.go on lines 4389..4470
api/dispatcher.pb.go on lines 4555..4636
api/health.pb.go on lines 538..619
api/raft.pb.go on lines 3154..3235
api/raft.pb.go on lines 3892..3973
api/resource.pb.go on lines 930..1011
api/resource.pb.go on lines 1012..1093
api/specs.pb.go on lines 6296..6377
api/specs.pb.go on lines 7535..7616

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

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

func (m *ResolveAddressResponse) Unmarshal(dAtA []byte) error {
    l := len(dAtA)
    iNdEx := 0
    for iNdEx < l {
        preIndex := iNdEx
Severity: Major
Found in api/raft.pb.go and 10 other locations - About 1 day to fix
api/ca.pb.go on lines 1585..1666
api/dispatcher.pb.go on lines 3672..3753
api/dispatcher.pb.go on lines 4389..4470
api/dispatcher.pb.go on lines 4555..4636
api/health.pb.go on lines 538..619
api/raft.pb.go on lines 3154..3235
api/resource.pb.go on lines 930..1011
api/resource.pb.go on lines 1012..1093
api/specs.pb.go on lines 6296..6377
api/specs.pb.go on lines 7535..7616

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

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

func Do(ctx context.Context, task *api.Task, ctlr Controller) (*api.TaskStatus, error) {
    status := task.Status.Copy()

    // stay in the current state.
    noop := func(errs ...error) (*api.TaskStatus, error) {
Severity: Minor
Found in agent/exec/controller.go - About 1 day 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 dumpWAL has a Cognitive Complexity of 67 (exceeds 20 allowed). Consider refactoring.
Open

func dumpWAL(swarmdir, unlockKey string, start, end uint64, redact bool) error {
    walData, _, err := loadData(swarmdir, unlockKey)
    if err != nil {
        return err
    }
Severity: Minor
Found in swarmd/cmd/swarm-rafttool/dump.go - About 1 day 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.ListNodes has a Cognitive Complexity of 66 (exceeds 20 allowed). Consider refactoring.
Open

func (s *Server) ListNodes(ctx context.Context, request *api.ListNodesRequest) (*api.ListNodesResponse, error) {
    var (
        nodes []*api.Node
        err   error
    )
Severity: Minor
Found in manager/controlapi/node.go - About 7 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

File storeobject.go has 743 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package storeobject

import (
    "strings"

Severity: Minor
Found in protobuf/plugin/storeobject/storeobject.go - About 7 hrs to fix

    Function printServiceSummary has a Cognitive Complexity of 65 (exceeds 20 allowed). Consider refactoring.
    Open

    func printServiceSummary(service *api.Service, running int) {
        w := tabwriter.NewWriter(os.Stdout, 8, 8, 8, ' ', 0)
        defer w.Flush()
    
        task := service.Spec.Task
    Severity: Minor
    Found in swarmd/cmd/swarmctl/service/inspect.go - About 7 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 ReplicatedJob.Unmarshal has a Cognitive Complexity of 65 (exceeds 20 allowed). Consider refactoring.
    Open

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

      Method Cluster.Unmarshal has 90 return statements (exceeds 4 allowed).
      Open

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

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

                case 3:
                    if wireType == 0 {
                        var v uint64
                        for shift := uint(0); ; shift += 7 {
                            if shift >= 64 {
        Severity: Major
        Found in api/raft.pb.go and 1 other location - About 7 hrs to fix
        api/snapshot.pb.go on lines 1296..1371

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

        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

                case 2:
                    if wireType == 0 {
                        var v uint64
                        for shift := uint(0); ; shift += 7 {
                            if shift >= 64 {
        Severity: Major
        Found in api/snapshot.pb.go and 1 other location - About 7 hrs to fix
        api/raft.pb.go on lines 3318..3393

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

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

        func (tm *taskManager) run(ctx context.Context) {
            ctx, cancelAll := context.WithCancel(ctx)
            defer cancelAll() // cancel all child operations on exit.
        
            ctx = log.WithModule(ctx, "taskmanager")
        Severity: Minor
        Found in agent/task.go - About 7 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 Resource.Unmarshal has 213 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

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

          func (m *StoreObject) Unmarshal(dAtA []byte) error {
              var hasFields [1]uint64
              l := len(dAtA)
              iNdEx := 0
              for iNdEx < l {
          Severity: Minor
          Found in protobuf/plugin/plugin.pb.go - About 7 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 ProcessRaftMessageRequest.Unmarshal has a Cognitive Complexity of 62 (exceeds 20 allowed). Consider refactoring.
          Open

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

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

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

          func (tr *TaskReaper) tick() {
              // this signals that a tick has occurred. it exists solely for testing.
              if tr.tickSignal != nil {
                  // try writing to this channel, but if it's full, fall straight through
                  // and ignore it.
          Severity: Minor
          Found in manager/orchestrator/taskreaper/task_reaper.go - About 7 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

          Severity
          Category
          Status
          Source
          Language