docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

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

func (m *UpdateTaskStatusRequest) Size() (n int) {
    if m == nil {
        return 0
    }
    var l int
Severity: Major
Found in api/dispatcher.pb.go and 1 other location - About 1 hr to fix
api/dispatcher.pb.go on lines 2892..2909

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

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

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

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

func (sr *statusReporter) run(ctx context.Context) {
    done := make(chan struct{})
    defer close(done)

    sr.mu.Lock() // released during wait, below.
Severity: Minor
Found in agent/reporter.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 TaskSpec.MarshalToSizedBuffer has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (m *TaskSpec) 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 rootRotationReconciler.runReconcilerLoop has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (r *rootRotationReconciler) runReconcilerLoop(ctx context.Context, loopRootCA *api.RootCA) {
    defer r.wg.Done()
    for {
        r.mu.Lock()
        if len(r.unconvergedNodes) == 0 {
Severity: Minor
Found in ca/reconciler.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 Server.Run has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (s *Server) Run(ctx context.Context) error {
    s.mu.Lock()
    if s.isRunning() {
        s.mu.Unlock()
        return errors.New("CA signer is already running")
Severity: Minor
Found in ca/server.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 StoreObject.Unmarshal has 17 return statements (exceeds 4 allowed).
Open

func (m *StoreObject) Unmarshal(dAtA []byte) error {
    var hasFields [1]uint64
    l := len(dAtA)
    iNdEx := 0
    for iNdEx < l {
Severity: Major
Found in protobuf/plugin/plugin.pb.go - About 1 hr to fix

    Method deepCopyGen.genMsgDeepCopy has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
    Open

    func (d *deepCopyGen) genMsgDeepCopy(m *generator.Descriptor) {
        ccTypeName := generator.CamelCaseSlice(m.TypeName())
    
        // Generate backwards compatible, type-safe Copy() function.
        d.P("func (m *", ccTypeName, ") Copy() *", ccTypeName, "{")
    Severity: Minor
    Found in protobuf/plugin/deepcopy/deepcopy.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.Run has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
    Open

    func (g *Orchestrator) Run(ctx context.Context) error {
        defer close(g.doneChan)
    
        // Watch changes to services and tasks
        queue := g.store.WatchQueue()
    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

    Method Manager.handleVolume has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
    Open

    func (vm *Manager) handleVolume(ctx context.Context, id string) error {
        var volume *api.Volume
        vm.store.View(func(tx store.ReadTx) {
            volume = store.GetVolume(tx, id)
        })
    Severity: Minor
    Found in manager/csi/manager.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 validateCAConfig has 17 return statements (exceeds 4 allowed).
    Open

    func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cluster *api.Cluster) (*api.RootCA, error) {
        newConfig := cluster.Spec.CAConfig.Copy()
        newConfig.SigningCACert = ca.NormalizePEMs(newConfig.SigningCACert) // ensure this is normalized before we use it
    
        if len(newConfig.SigningCAKey) > 0 && len(newConfig.SigningCACert) == 0 {
    Severity: Major
    Found in manager/controlapi/ca_rotation.go - About 1 hr to fix

      Method Collector.Run has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
      Open

      func (c *Collector) Run(ctx context.Context) error {
          defer close(c.doneChan)
      
          watcher, cancel, err := store.ViewAndWatch(c.store, func(readTx store.ReadTx) error {
              nodes, err := store.FindNodes(readTx, store.All)
      Severity: Minor
      Found in manager/metrics/collector.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 2 locations. Consider refactoring.
      Open

          switch v := ev.(type) {
          case api.EventCreateNode:
              a.store.View(func(tx store.ReadTx) {
                  node = store.GetNode(tx, v.Node.ID)
              })
      Severity: Major
      Found in manager/allocator/network.go and 1 other location - About 1 hr to fix
      manager/allocator/network.go on lines 882..894

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

      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

          switch v := ev.(type) {
          case api.EventCreateTask:
              a.store.View(func(tx store.ReadTx) {
                  t = store.GetTask(tx, v.Task.ID)
              })
      Severity: Major
      Found in manager/allocator/network.go and 1 other location - About 1 hr to fix
      manager/allocator/network.go on lines 307..319

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

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

      func renewCerts(swarmdir, unlockKey string) error {
          // First, load the existing cert.  We don't actually bother to check if
          // it's expired - this will just obtain a new cert anyway.
          krw, err := getKRW(swarmdir, unlockKey)
          if err != nil {
      Severity: Minor
      Found in swarmd/cmd/swarm-rafttool/renewcert.go - About 1 hr to fix

        Method Server.UpdateCluster has 64 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (s *Server) UpdateCluster(ctx context.Context, request *api.UpdateClusterRequest) (*api.UpdateClusterResponse, error) {
            if request.ClusterID == "" || request.ClusterVersion == nil {
                return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
            }
            if err := validateClusterSpec(request.Spec); err != nil {
        Severity: Minor
        Found in manager/controlapi/cluster.go - About 1 hr to fix

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

          var (
              inspectCmd = &cobra.Command{
                  Use:   "inspect <config ID or name>",
                  Short: "Inspect a config",
                  RunE: func(cmd *cobra.Command, args []string) error {
          Severity: Major
          Found in swarmd/cmd/swarmctl/config/inspect.go and 1 other location - About 1 hr to fix
          swarmd/cmd/swarmctl/secret/inspect.go on lines 31..54

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

          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

          var (
              inspectCmd = &cobra.Command{
                  Use:   "inspect <secret ID or name>",
                  Short: "Inspect a secret",
                  RunE: func(cmd *cobra.Command, args []string) error {
          Severity: Major
          Found in swarmd/cmd/swarmctl/secret/inspect.go and 1 other location - About 1 hr to fix
          swarmd/cmd/swarmctl/config/inspect.go on lines 34..57

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

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

          func (a *Allocator) doTaskAlloc(ctx context.Context, ev events.Event) {
              var (
                  isDelete bool
                  t        *api.Task
              )
          Severity: Minor
          Found in manager/allocator/network.go - About 1 hr to fix

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

            func (m *ProcessRaftMessageRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
                i := len(dAtA)
                _ = i
                var l int
                _ = l
            Severity: Major
            Found in api/raft.pb.go and 2 other locations - About 1 hr to fix
            api/raft.pb.go on lines 1568..1586
            api/raft.pb.go on lines 1684..1702

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

            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