docker/swarmkit

View on GitHub

Showing 1,820 of 1,820 total issues

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

func (this *ContainerSpec_DNSConfig) String() string {
    if this == nil {
        return "nil"
    }
    s := strings.Join([]string{`&ContainerSpec_DNSConfig{`,
Severity: Major
Found in api/specs.pb.go and 4 other locations - About 1 hr to fix
api/logbroker.pb.go on lines 2251..2262
api/logbroker.pb.go on lines 2263..2274
api/specs.pb.go on lines 4769..4780
api/watch.pb.go on lines 2826..2837

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

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

func (this *LogSelector) String() string {
    if this == nil {
        return "nil"
    }
    s := strings.Join([]string{`&LogSelector{`,
Severity: Major
Found in api/logbroker.pb.go and 4 other locations - About 1 hr to fix
api/logbroker.pb.go on lines 2263..2274
api/specs.pb.go on lines 4757..4768
api/specs.pb.go on lines 4769..4780
api/watch.pb.go on lines 2826..2837

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

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

func (this *LogContext) String() string {
    if this == nil {
        return "nil"
    }
    s := strings.Join([]string{`&LogContext{`,
Severity: Major
Found in api/logbroker.pb.go and 4 other locations - About 1 hr to fix
api/logbroker.pb.go on lines 2251..2262
api/specs.pb.go on lines 4757..4768
api/specs.pb.go on lines 4769..4780
api/watch.pb.go on lines 2826..2837

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

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

func (this *ContainerSpec_Ulimit) String() string {
    if this == nil {
        return "nil"
    }
    s := strings.Join([]string{`&ContainerSpec_Ulimit{`,
Severity: Major
Found in api/specs.pb.go and 4 other locations - About 1 hr to fix
api/logbroker.pb.go on lines 2251..2262
api/logbroker.pb.go on lines 2263..2274
api/specs.pb.go on lines 4757..4768
api/watch.pb.go on lines 2826..2837

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

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

func (this *SelectByCustom) String() string {
    if this == nil {
        return "nil"
    }
    s := strings.Join([]string{`&SelectByCustom{`,
Severity: Major
Found in api/watch.pb.go and 4 other locations - About 1 hr to fix
api/logbroker.pb.go on lines 2251..2262
api/logbroker.pb.go on lines 2263..2274
api/specs.pb.go on lines 4757..4768
api/specs.pb.go on lines 4769..4780

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

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 (k configSorter) Less(i, j int) bool {
    iTime, err := gogotypes.TimestampFromProto(k[i].Meta.CreatedAt)
    if err != nil {
        panic(err)
    }
Severity: Minor
Found in swarmd/cmd/swarmctl/config/list.go and 1 other location - About 1 hr to fix
swarmd/cmd/swarmctl/secret/list.go on lines 21..31

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

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 (k secretSorter) Less(i, j int) bool {
    iTime, err := gogotypes.TimestampFromProto(k[i].Meta.CreatedAt)
    if err != nil {
        panic(err)
    }
Severity: Minor
Found in swarmd/cmd/swarmctl/secret/list.go and 1 other location - About 1 hr to fix
swarmd/cmd/swarmctl/config/list.go on lines 21..31

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

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

    if err := batch.Update(func(tx store.Tx) error {
        err := store.UpdateService(tx, s)

        if err == store.ErrSequenceConflict {
            storeService := store.GetService(tx, s.ID)
Severity: Minor
Found in manager/allocator/network.go and 1 other location - About 55 mins to fix
manager/allocator/network.go on lines 1106..1122

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

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

    if err := batch.Update(func(tx store.Tx) error {
        err := store.UpdateNode(tx, node)

        if err == store.ErrSequenceConflict {
            storeNode := store.GetNode(tx, node.ID)
Severity: Minor
Found in manager/allocator/network.go and 1 other location - About 55 mins to fix
manager/allocator/network.go on lines 1248..1264

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

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

    suite.NoError(s.Update(func(tx store.Tx) error {
        // create a task assigned to this node that has a network attachment on
        // n1
        t3 := &api.Task{
            ID:           "task3",
Severity: Major
Found in manager/allocator/allocator_test_suite.go and 2 other locations - About 55 mins to fix
manager/allocator/allocator_test_suite.go on lines 1271..1288
manager/allocator/allocator_test_suite.go on lines 1329..1346

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

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

    suite.NoError(s.Update(func(tx store.Tx) error {
        // create a task assigned to this node that has a network attachment on
        // n1
        t1 := &api.Task{
            ID:           "task1",
Severity: Major
Found in manager/allocator/allocator_test_suite.go and 2 other locations - About 55 mins to fix
manager/allocator/allocator_test_suite.go on lines 1329..1346
manager/allocator/allocator_test_suite.go on lines 1356..1373

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

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

    suite.NoError(s.Update(func(tx store.Tx) error {
        // create a task assigned to this node that has a network attachment on
        // n1
        t2 := &api.Task{
            ID:           "task2",
Severity: Major
Found in manager/allocator/allocator_test_suite.go and 2 other locations - About 55 mins to fix
manager/allocator/allocator_test_suite.go on lines 1271..1288
manager/allocator/allocator_test_suite.go on lines 1356..1373

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

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 raftProxyNodeCAServer.NodeCertificateStatus has 9 return statements (exceeds 4 allowed).
Open

func (p *raftProxyNodeCAServer) NodeCertificateStatus(ctx context.Context, r *NodeCertificateStatusRequest) (*NodeCertificateStatusResponse, error) {

    conn, err := p.connSelector.LeaderConn(ctx)
    if err != nil {
        if err == raftselector.ErrIsLeader {
Severity: Major
Found in api/ca.pb.go - About 55 mins to fix

    Method controller.Wait has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
    Open

    func (r *controller) Wait(ctx context.Context) error {
        if err := r.checkClosed(); err != nil {
            return err
        }
    
    
    Severity: Minor
    Found in swarmd/dockerexec/controller.go - About 55 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 raftProxyHealthServer.Check has 9 return statements (exceeds 4 allowed).
    Open

    func (p *raftProxyHealthServer) Check(ctx context.Context, r *HealthCheckRequest) (*HealthCheckResponse, error) {
    
        conn, err := p.connSelector.LeaderConn(ctx)
        if err != nil {
            if err == raftselector.ErrIsLeader {
    Severity: Major
    Found in api/health.pb.go - About 55 mins to fix

      Method raftProxyNodeCAServer.IssueNodeCertificate has 9 return statements (exceeds 4 allowed).
      Open

      func (p *raftProxyNodeCAServer) IssueNodeCertificate(ctx context.Context, r *IssueNodeCertificateRequest) (*IssueNodeCertificateResponse, error) {
      
          conn, err := p.connSelector.LeaderConn(ctx)
          if err != nil {
              if err == raftselector.ErrIsLeader {
      Severity: Major
      Found in api/ca.pb.go - About 55 mins to fix

        Method raftProxyCAServer.GetUnlockKey has 9 return statements (exceeds 4 allowed).
        Open

        func (p *raftProxyCAServer) GetUnlockKey(ctx context.Context, r *GetUnlockKeyRequest) (*GetUnlockKeyResponse, error) {
        
            conn, err := p.connSelector.LeaderConn(ctx)
            if err != nil {
                if err == raftselector.ErrIsLeader {
        Severity: Major
        Found in api/ca.pb.go - About 55 mins to fix

          Function getMountMask has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func getMountMask(m *api.Mount) string {
              var maskOpts []string
              if m.ReadOnly {
                  maskOpts = append(maskOpts, "ro")
              }
          Severity: Minor
          Found in swarmd/dockerexec/container.go - About 55 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 raftProxyCAServer.GetRootCACertificate has 9 return statements (exceeds 4 allowed).
          Open

          func (p *raftProxyCAServer) GetRootCACertificate(ctx context.Context, r *GetRootCACertificateRequest) (*GetRootCACertificateResponse, error) {
          
              conn, err := p.connSelector.LeaderConn(ctx)
              if err != nil {
                  if err == raftselector.ErrIsLeader {
          Severity: Major
          Found in api/ca.pb.go - About 55 mins to fix

            Method DetachNetworkResponse.Unmarshal has 9 return statements (exceeds 4 allowed).
            Open

            func (m *DetachNetworkResponse) Unmarshal(dAtA []byte) error {
                l := len(dAtA)
                iNdEx := 0
                for iNdEx < l {
                    preIndex := iNdEx
            Severity: Major
            Found in api/resource.pb.go - About 55 mins to fix
              Severity
              Category
              Status
              Source
              Language