asteris-llc/converge

View on GitHub
graph/node/conditional/conditional_test.go

Summary

Maintainability
F
4 days
Test Coverage

Function peerBranchSampleGraph has 146 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func peerBranchSampleGraph(t *testing.T) *graph.Graph {
    g := graph.New()

    g.Add(node.New(graph.ID("root"), struct{}{}))
    g.Add(node.New(graph.ID("root", "switch1"), struct{}{}))
Severity: Major
Found in graph/node/conditional/conditional_test.go - About 4 hrs to fix

    Function TestShouldEvaluate has 115 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestShouldEvaluate(t *testing.T) {
        t.Run("when-many-branches", func(t *testing.T) {
            g := peerBranchSampleGraph(t)
            resources := []string{"resource1", "resource2", "resource3"}
            t.Run("when-true-true-true", func(t *testing.T) {
    Severity: Major
    Found in graph/node/conditional/conditional_test.go - About 3 hrs to fix

      Function TestShouldEvaluate has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
      Open

      func TestShouldEvaluate(t *testing.T) {
          t.Run("when-many-branches", func(t *testing.T) {
              g := peerBranchSampleGraph(t)
              resources := []string{"resource1", "resource2", "resource3"}
              t.Run("when-true-true-true", func(t *testing.T) {
      Severity: Minor
      Found in graph/node/conditional/conditional_test.go - About 2 hrs 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 conditional_test.go has 537 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package conditional_test
      
      import (
          "errors"
          "fmt"
      Severity: Minor
      Found in graph/node/conditional/conditional_test.go - About 2 hrs to fix

        Function TestIsTrue has 52 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestIsTrue(t *testing.T) {
            t.Run("errors-when-unrendered", func(t *testing.T) {
                g := sampleGraph()
                meta, _ := g.Get("root/b")
                _, err := conditional.IsTrue(meta)
        Severity: Minor
        Found in graph/node/conditional/conditional_test.go - About 1 hr to fix

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

                  t.Run("when-false-true-true", func(t *testing.T) {
                      t.Run("first-branch", func(t *testing.T) {
                          branch := "root/switch2/case1"
                          for _, res := range resources {
                              id := graph.ID(branch, res)
          Severity: Major
          Found in graph/node/conditional/conditional_test.go and 2 other locations - About 5 hrs to fix
          graph/node/conditional/conditional_test.go on lines 227..261
          graph/node/conditional/conditional_test.go on lines 297..331

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

          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

                  t.Run("when-false-false-true", func(t *testing.T) {
                      t.Run("first-branch", func(t *testing.T) {
                          branch := "root/switch3/case1"
                          for _, res := range resources {
                              id := graph.ID(branch, res)
          Severity: Major
          Found in graph/node/conditional/conditional_test.go and 2 other locations - About 5 hrs to fix
          graph/node/conditional/conditional_test.go on lines 227..261
          graph/node/conditional/conditional_test.go on lines 262..296

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

          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

                  t.Run("when-true-true-true", func(t *testing.T) {
                      t.Run("first-branch", func(t *testing.T) {
                          branch := "root/switch1/case1"
                          for _, res := range resources {
                              id := graph.ID(branch, res)
          Severity: Major
          Found in graph/node/conditional/conditional_test.go and 2 other locations - About 5 hrs to fix
          graph/node/conditional/conditional_test.go on lines 262..296
          graph/node/conditional/conditional_test.go on lines 297..331

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

          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

                  for _, truth := range truthyValues {
                      g := sampleGraph()
                      meta, _ := g.Get("root/b")
                      graphutils.AddMetadata(g, "root/b", conditional.MetaRenderedPredicate, truth)
                      graphutils.AddMetadata(g, "root/b", conditional.MetaPredicate, false)
          Severity: Minor
          Found in graph/node/conditional/conditional_test.go and 1 other location - About 35 mins to fix
          graph/node/conditional/conditional_test.go on lines 198..206

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

          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

                  for _, truth := range untruthyValues {
                      g := sampleGraph()
                      meta, _ := g.Get("root/b")
                      graphutils.AddMetadata(g, "root/b", conditional.MetaRenderedPredicate, truth)
                      graphutils.AddMetadata(g, "root/b", conditional.MetaPredicate, true)
          Severity: Minor
          Found in graph/node/conditional/conditional_test.go and 1 other location - About 35 mins to fix
          graph/node/conditional/conditional_test.go on lines 210..218

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

          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