docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

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

func (this *UpdateVolumeStatusRequest_VolumeStatusUpdate) String() string {
    if this == nil {
        return "nil"
    }
    s := strings.Join([]string{`&UpdateVolumeStatusRequest_VolumeStatusUpdate{`,
Severity: Major
Found in api/dispatcher.pb.go and 7 other locations - About 35 mins to fix
api/ca.pb.go on lines 1527..1537
api/logbroker.pb.go on lines 2275..2285
api/objects.pb.go on lines 6088..6098
api/raft.pb.go on lines 2869..2879
api/specs.pb.go on lines 4559..4569
api/specs.pb.go on lines 4636..4646
api/watch.pb.go on lines 2815..2825

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

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 encodeVarintLogbroker(dAtA []byte, offset int, v uint64) int {
    offset -= sovLogbroker(v)
    base := offset
    for v >= 1<<7 {
        dAtA[offset] = uint8(v&0x7f | 0x80)
Severity: Major
Found in api/logbroker.pb.go and 10 other locations - About 35 mins to fix
api/ca.pb.go on lines 1076..1086
api/dispatcher.pb.go on lines 2431..2441
api/health.pb.go on lines 360..370
api/objects.pb.go on lines 2619..2629
api/raft.pb.go on lines 2074..2084
api/resource.pb.go on lines 552..562
api/snapshot.pb.go on lines 616..626
api/specs.pb.go on lines 3796..3806
api/watch.pb.go on lines 2137..2147
protobuf/plugin/plugin.pb.go on lines 526..536

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

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 encodeVarintPlugin(dAtA []byte, offset int, v uint64) int {
    offset -= sovPlugin(v)
    base := offset
    for v >= 1<<7 {
        dAtA[offset] = uint8(v&0x7f | 0x80)
Severity: Major
Found in protobuf/plugin/plugin.pb.go and 10 other locations - About 35 mins to fix
api/ca.pb.go on lines 1076..1086
api/dispatcher.pb.go on lines 2431..2441
api/health.pb.go on lines 360..370
api/logbroker.pb.go on lines 1704..1714
api/objects.pb.go on lines 2619..2629
api/raft.pb.go on lines 2074..2084
api/resource.pb.go on lines 552..562
api/snapshot.pb.go on lines 616..626
api/specs.pb.go on lines 3796..3806
api/watch.pb.go on lines 2137..2147

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

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

func (this *Endpoint_VirtualIP) String() string {
    if this == nil {
        return "nil"
    }
    s := strings.Join([]string{`&Endpoint_VirtualIP{`,
Severity: Major
Found in api/objects.pb.go and 7 other locations - About 35 mins to fix
api/ca.pb.go on lines 1527..1537
api/dispatcher.pb.go on lines 3192..3202
api/logbroker.pb.go on lines 2275..2285
api/raft.pb.go on lines 2869..2879
api/specs.pb.go on lines 4559..4569
api/specs.pb.go on lines 4636..4646
api/watch.pb.go on lines 2815..2825

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

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 (x *raftStreamRaftMessageClient) CloseAndRecv() (*StreamRaftMessageResponse, error) {
    if err := x.ClientStream.CloseSend(); err != nil {
        return nil, err
    }
    m := new(StreamRaftMessageResponse)
Severity: Minor
Found in api/raft.pb.go and 1 other location - About 35 mins to fix
api/logbroker.pb.go on lines 1092..1101

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

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 (x *logBrokerPublishLogsClient) CloseAndRecv() (*PublishLogsResponse, error) {
    if err := x.ClientStream.CloseSend(); err != nil {
        return nil, err
    }
    m := new(PublishLogsResponse)
Severity: Minor
Found in api/logbroker.pb.go and 1 other location - About 35 mins to fix
api/raft.pb.go on lines 1172..1181

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

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 nodePlugin.NodeUnpublishVolume has 5 return statements (exceeds 4 allowed).
Open

func (np *nodePlugin) NodeUnpublishVolume(ctx context.Context, req *api.VolumeAssignment) error {
    // Check arguments
    if len(req.VolumeID) == 0 {
        return status.Error(codes.InvalidArgument, "Volume ID missing in request")
    }
Severity: Major
Found in agent/csi/plugin/plugin.go - About 35 mins to fix

    Method Config.validate has 5 return statements (exceeds 4 allowed).
    Open

    func (c *Config) validate() error {
        if c.Credentials == nil {
            return errors.New("agent: Credentials is required")
        }
    
    
    Severity: Major
    Found in agent/config.go - About 35 mins to fix

      Function getService has 5 return statements (exceeds 4 allowed).
      Open

      func getService(ctx context.Context, c api.ControlClient, input string) (*api.Service, error) {
          // GetService to match via full ID.
          rg, err := c.GetService(ctx, &api.GetServiceRequest{ServiceID: input})
          if err != nil {
              // If any error (including NotFound), ListServices to match via full name.
      Severity: Major
      Found in swarmd/cmd/swarmctl/service/common.go - About 35 mins to fix

        Method PayloadContext.configGetter has 5 return statements (exceeds 4 allowed).
        Open

        func (ctx *PayloadContext) configGetter(target string) (string, error) {
            if ctx.restrictedConfigs == nil {
                return "", errors.New("configs unavailable")
            }
        
        
        Severity: Major
        Found in template/context.go - About 35 mins to fix

          Function printClusterSummary has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
          Open

          func printClusterSummary(cluster *api.Cluster) {
              w := tabwriter.NewWriter(os.Stdout, 8, 8, 8, ' ', 0)
              defer w.Flush()
          
              common.FprintfIfNotEmpty(w, "ID\t: %s\n", cluster.ID)
          Severity: Minor
          Found in swarmd/cmd/swarmctl/cluster/inspect.go - About 35 mins 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 templatedConfigGetter.GetAndFlagSecretData has 5 return statements (exceeds 4 allowed).
          Open

          func (t templatedConfigGetter) GetAndFlagSecretData(configID string) (*api.Config, bool, error) {
              if t.dependencies == nil {
                  return nil, false, errors.New("no config provider available")
              }
          
          
          Severity: Major
          Found in template/getter.go - About 35 mins to fix

            Method worker.Update has 5 return statements (exceeds 4 allowed).
            Open

            func (w *worker) Update(ctx context.Context, assignments []*api.AssignmentChange) error {
                w.mu.Lock()
                defer w.mu.Unlock()
            
                if w.closed {
            Severity: Major
            Found in agent/worker.go - About 35 mins to fix

              Function getCluster has 5 return statements (exceeds 4 allowed).
              Open

              func getCluster(ctx context.Context, c api.ControlClient, input string) (*api.Cluster, error) {
                  rg, err := c.GetCluster(ctx, &api.GetClusterRequest{ClusterID: input})
                  if err == nil {
                      return rg.Cluster, nil
                  }
              Severity: Major
              Found in swarmd/cmd/swarmctl/cluster/common.go - About 35 mins to fix

                Method nodePlugin.NodePublishVolume has 5 return statements (exceeds 4 allowed).
                Open

                func (np *nodePlugin) NodePublishVolume(ctx context.Context, req *api.VolumeAssignment) error {
                    err := capability.CheckArguments(req)
                    if err != nil {
                        return err
                    }
                Severity: Major
                Found in agent/csi/plugin/plugin.go - About 35 mins to fix

                  Method Agent.withSession has 5 return statements (exceeds 4 allowed).
                  Open

                  func (a *Agent) withSession(ctx context.Context, fn func(session *session) error) error {
                      response := make(chan error, 1)
                      select {
                      case a.sessionq <- sessionOperation{
                          fn:       fn,
                  Severity: Major
                  Found in agent/agent.go - About 35 mins to fix

                    Function getNode has 5 return statements (exceeds 4 allowed).
                    Open

                    func getNode(ctx context.Context, c api.ControlClient, input string) (*api.Node, error) {
                        // GetNode to match via full ID.
                        rg, err := c.GetNode(ctx, &api.GetNodeRequest{NodeID: input})
                        if err != nil {
                            // If any error (including NotFound), ListServices to match via full name.
                    Severity: Major
                    Found in swarmd/cmd/swarmctl/node/common.go - About 35 mins to fix

                      Method worker.Assign has 5 return statements (exceeds 4 allowed).
                      Open

                      func (w *worker) Assign(ctx context.Context, assignments []*api.AssignmentChange) error {
                          w.mu.Lock()
                          defer w.mu.Unlock()
                      
                          if w.closed {
                      Severity: Major
                      Found in agent/worker.go - About 35 mins to fix

                        Function dumpWAL has 5 return statements (exceeds 4 allowed).
                        Open

                        func dumpWAL(swarmdir, unlockKey string, start, end uint64, redact bool) error {
                            walData, _, err := loadData(swarmdir, unlockKey)
                            if err != nil {
                                return err
                            }
                        Severity: Major
                        Found in swarmd/cmd/swarm-rafttool/dump.go - About 35 mins to fix

                          Method templatedSecretGetter.Get has 5 return statements (exceeds 4 allowed).
                          Open

                          func (t templatedSecretGetter) Get(secretID string) (*api.Secret, error) {
                              if t.dependencies == nil {
                                  return nil, errors.New("no secret provider available")
                              }
                          
                          
                          Severity: Major
                          Found in template/getter.go - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language