dotcloud/docker

View on GitHub
daemon/cluster/helpers.go

Summary

Maintainability
D
2 days
Test Coverage

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

func getService(ctx context.Context, c swarmapi.ControlClient, input string, insertDefaults bool) (*swarmapi.Service, error) {
    // GetService to match via full ID.
    if rg, err := c.GetService(ctx, &swarmapi.GetServiceRequest{ServiceID: input, InsertDefaults: insertDefaults}); err == nil {
        return rg.Service, nil
    }
Severity: Major
Found in daemon/cluster/helpers.go - About 45 mins to fix

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

    func getNode(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Node, error) {
        // GetNode to match via full ID.
        if rg, err := c.GetNode(ctx, &swarmapi.GetNodeRequest{NodeID: input}); err == nil {
            return rg.Node, nil
        }
    Severity: Major
    Found in daemon/cluster/helpers.go - About 35 mins to fix

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

      func getConfig(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Config, error) {
          // attempt to lookup config by full ID
          if rg, err := c.GetConfig(ctx, &swarmapi.GetConfigRequest{ConfigID: input}); err == nil {
              return rg.Config, nil
          }
      Severity: Major
      Found in daemon/cluster/helpers.go - About 35 mins to fix

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

        func getVolume(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Volume, error) {
            // GetVolume to match via full ID
            if v, err := c.GetVolume(ctx, &swarmapi.GetVolumeRequest{VolumeID: input}); err == nil {
                return v.Volume, nil
            }
        Severity: Major
        Found in daemon/cluster/helpers.go - About 35 mins to fix

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

          func getNetwork(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Network, error) {
              // GetNetwork to match via full ID.
              if rg, err := c.GetNetwork(ctx, &swarmapi.GetNetworkRequest{NetworkID: input}); err == nil {
                  return rg.Network, nil
              }
          Severity: Major
          Found in daemon/cluster/helpers.go - About 35 mins to fix

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

            func getTask(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Task, error) {
                // GetTask to match via full ID.
                if rg, err := c.GetTask(ctx, &swarmapi.GetTaskRequest{TaskID: input}); err == nil {
                    return rg.Task, nil
                }
            Severity: Major
            Found in daemon/cluster/helpers.go - About 35 mins to fix

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

              func getSecret(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Secret, error) {
                  // attempt to lookup secret by full ID
                  if rg, err := c.GetSecret(ctx, &swarmapi.GetSecretRequest{SecretID: input}); err == nil {
                      return rg.Secret, nil
                  }
              Severity: Major
              Found in daemon/cluster/helpers.go - About 35 mins to fix

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

                func getConfig(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Config, error) {
                    // attempt to lookup config by full ID
                    if rg, err := c.GetConfig(ctx, &swarmapi.GetConfigRequest{ConfigID: input}); err == nil {
                        return rg.Config, nil
                    }
                Severity: Major
                Found in daemon/cluster/helpers.go and 3 other locations - About 4 hrs to fix
                daemon/cluster/helpers.go on lines 26..60
                daemon/cluster/helpers.go on lines 106..140
                daemon/cluster/helpers.go on lines 142..176

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

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

                func getSecret(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Secret, error) {
                    // attempt to lookup secret by full ID
                    if rg, err := c.GetSecret(ctx, &swarmapi.GetSecretRequest{SecretID: input}); err == nil {
                        return rg.Secret, nil
                    }
                Severity: Major
                Found in daemon/cluster/helpers.go and 3 other locations - About 4 hrs to fix
                daemon/cluster/helpers.go on lines 26..60
                daemon/cluster/helpers.go on lines 106..140
                daemon/cluster/helpers.go on lines 178..212

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

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

                func getNode(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Node, error) {
                    // GetNode to match via full ID.
                    if rg, err := c.GetNode(ctx, &swarmapi.GetNodeRequest{NodeID: input}); err == nil {
                        return rg.Node, nil
                    }
                Severity: Major
                Found in daemon/cluster/helpers.go and 3 other locations - About 4 hrs to fix
                daemon/cluster/helpers.go on lines 106..140
                daemon/cluster/helpers.go on lines 142..176
                daemon/cluster/helpers.go on lines 178..212

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

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

                func getTask(ctx context.Context, c swarmapi.ControlClient, input string) (*swarmapi.Task, error) {
                    // GetTask to match via full ID.
                    if rg, err := c.GetTask(ctx, &swarmapi.GetTaskRequest{TaskID: input}); err == nil {
                        return rg.Task, nil
                    }
                Severity: Major
                Found in daemon/cluster/helpers.go and 3 other locations - About 4 hrs to fix
                daemon/cluster/helpers.go on lines 26..60
                daemon/cluster/helpers.go on lines 142..176
                daemon/cluster/helpers.go on lines 178..212

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

                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

                There are no issues that match your filters.

                Category
                Status