docker/swarmkit

View on GitHub
protobuf/plugin/storeobject/storeobject.go

Summary

Maintainability
F
1 wk
Test Coverage

Method storeObjectGen.genMsgStoreObject has 533 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (d *storeObjectGen) genMsgStoreObject(m *generator.Descriptor, storeObject *plugin.StoreObject) {
    ccTypeName := generator.CamelCaseSlice(m.TypeName())

    // Generate event types

Severity: Major
Found in protobuf/plugin/storeobject/storeobject.go - About 2 days to fix

    Method storeObjectGen.genMsgStoreObject has a Cognitive Complexity of 94 (exceeds 20 allowed). Consider refactoring.
    Open

    func (d *storeObjectGen) genMsgStoreObject(m *generator.Descriptor, storeObject *plugin.StoreObject) {
        ccTypeName := generator.CamelCaseSlice(m.TypeName())
    
        // Generate event types
    
    
    Severity: Minor
    Found in protobuf/plugin/storeobject/storeobject.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

    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

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

          if storeObject.WatchSelectors.Name != nil && *storeObject.WatchSelectors.Name {
              d.P("case *SelectBy_Name:")
              d.In()
              if *m.Name == "Node" {
                  d.P("if m.Description != nil {")
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 1 other location - About 3 hrs to fix
      protobuf/plugin/storeobject/storeobject.go on lines 427..455

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

      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 storeObject.WatchSelectors.NamePrefix != nil && *storeObject.WatchSelectors.NamePrefix {
              d.P("case *SelectBy_NamePrefix:")
              d.In()
              if *m.Name == "Node" {
                  d.P("if m.Description != nil {")
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 1 other location - About 3 hrs to fix
      protobuf/plugin/storeobject/storeobject.go on lines 398..426

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

      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 storeObject.WatchSelectors.Custom != nil && *storeObject.WatchSelectors.Custom {
              d.P("case *SelectBy_Custom:")
              d.In()
              if _, hasNoSpec := typesWithNoSpec[*m.Name]; hasNoSpec {
                  d.P(`if len(m.Annotations.Indices) != 0 {`)
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 1 other location - About 2 hrs to fix
      protobuf/plugin/storeobject/storeobject.go on lines 477..497

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

      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 storeObject.WatchSelectors.CustomPrefix != nil && *storeObject.WatchSelectors.CustomPrefix {
              d.P("case *SelectBy_CustomPrefix:")
              d.In()
              if _, hasNoSpec := typesWithNoSpec[*m.Name]; hasNoSpec {
                  d.P(`if len(m.Annotations.Indices) != 0 {`)
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 1 other location - About 2 hrs to fix
      protobuf/plugin/storeobject/storeobject.go on lines 456..476

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

      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

          if storeObject.WatchSelectors.DesiredState != nil && *storeObject.WatchSelectors.DesiredState {
              d.P("case *SelectBy_DesiredState:")
              d.In()
              d.P(`if hasDesiredState {`)
              d.In()
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 2 other locations - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 548..560
      protobuf/plugin/storeobject/storeobject.go on lines 561..573

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

      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

          if storeObject.WatchSelectors.Membership != nil && *storeObject.WatchSelectors.Membership {
              d.P("case *SelectBy_Membership:")
              d.In()
              d.P(`if hasMembership {`)
              d.In()
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 2 other locations - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 535..547
      protobuf/plugin/storeobject/storeobject.go on lines 548..560

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

      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

          if storeObject.WatchSelectors.Role != nil && *storeObject.WatchSelectors.Role {
              d.P("case *SelectBy_Role:")
              d.In()
              d.P(`if hasRole {`)
              d.In()
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 2 other locations - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 535..547
      protobuf/plugin/storeobject/storeobject.go on lines 561..573

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

      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

          if storeObject.WatchSelectors.ID != nil && *storeObject.WatchSelectors.ID {
              d.P("case *SelectBy_ID:")
              d.In()
              d.P(`if m.ID != "" {`)
              d.In()
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 3 other locations - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 386..397
      protobuf/plugin/storeobject/storeobject.go on lines 498..509
      protobuf/plugin/storeobject/storeobject.go on lines 510..521

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

      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

          if storeObject.WatchSelectors.NodeID != nil && *storeObject.WatchSelectors.NodeID {
              d.P("case *SelectBy_NodeID:")
              d.In()
              d.P(`if m.NodeID != "" {`)
              d.In()
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 3 other locations - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 374..385
      protobuf/plugin/storeobject/storeobject.go on lines 386..397
      protobuf/plugin/storeobject/storeobject.go on lines 498..509

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

      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

          if storeObject.WatchSelectors.IDPrefix != nil && *storeObject.WatchSelectors.IDPrefix {
              d.P("case *SelectBy_IDPrefix:")
              d.In()
              d.P(`if m.ID != "" {`)
              d.In()
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 3 other locations - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 374..385
      protobuf/plugin/storeobject/storeobject.go on lines 498..509
      protobuf/plugin/storeobject/storeobject.go on lines 510..521

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

      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

          if storeObject.WatchSelectors.ServiceID != nil && *storeObject.WatchSelectors.ServiceID {
              d.P("case *SelectBy_ServiceID:")
              d.In()
              d.P(`if m.ServiceID != "" {`)
              d.In()
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 3 other locations - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 374..385
      protobuf/plugin/storeobject/storeobject.go on lines 386..397
      protobuf/plugin/storeobject/storeobject.go on lines 510..521

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

      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 storeObject.WatchSelectors.CustomPrefix != nil && *storeObject.WatchSelectors.CustomPrefix {
              d.P("func ", ccTypeName, "CheckCustomPrefix(v1, v2 *", ccTypeName, ") bool {")
              d.In()
              // Node is a special case
              if _, hasNoSpec := typesWithNoSpec[*m.Name]; hasNoSpec {
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 1 other location - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 252..264

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

      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 storeObject.WatchSelectors.Custom != nil && *storeObject.WatchSelectors.Custom {
              d.P("func ", ccTypeName, "CheckCustom(v1, v2 *", ccTypeName, ") bool {")
              d.In()
              // Node is a special case
              if _, hasNoSpec := typesWithNoSpec[*m.Name]; hasNoSpec {
      Severity: Major
      Found in protobuf/plugin/storeobject/storeobject.go and 1 other location - About 1 hr to fix
      protobuf/plugin/storeobject/storeobject.go on lines 266..278

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

      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