Showing 69 of 69 total issues

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

class TestDotGraph < Test::Unit::TestCase
  def test_graph_statement
    graph = DOT::Graph.new()
    dot   = graph.to_s
    assert_match(dot, /^\s*graph /)
Severity: Major
Found in test/rdot_test.rb and 2 other locations - About 2 days to fix
test/rdot_test.rb on lines 533..695
test/rdot_test.rb on lines 700..862

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

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

class TestDotSubgraph < Test::Unit::TestCase
  def test_subgraph_statement
    subgraph = DOT::Subgraph.new()
    dot      = subgraph.to_s
    assert_match(dot, /^\s*subgraph /)
Severity: Major
Found in test/rdot_test.rb and 2 other locations - About 2 days to fix
test/rdot_test.rb on lines 366..528
test/rdot_test.rb on lines 533..695

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

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

class TestDotDigraph < Test::Unit::TestCase
  def test_digraph_statement
    digraph = DOT::Digraph.new()
    dot     = digraph.to_s
    assert_match(dot, /^\s*digraph /)
Severity: Major
Found in test/rdot_test.rb and 2 other locations - About 2 days to fix
test/rdot_test.rb on lines 366..528
test/rdot_test.rb on lines 700..862

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

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

File rdot_test.rb has 671 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'test_helper'

require 'rgl/rdot'

include RGL
Severity: Major
Found in test/rdot_test.rb - About 1 day to fix

    File rdot.rb has 321 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module RGL
    
      # This is a modified version of +dot.rb+ from {https://ruby.github.io/rdoc Dave
      # Thomas's rdoc project}. I renamed it to +rdot.rb+ to avoid collision with an
      # installed rdoc/dot.
    Severity: Minor
    Found in lib/rgl/rdot.rb - About 3 hrs to fix

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

        def test_visitor
          visitor = DijkstraVisitor.new(@graph)
      
          events = []
      
      
      Severity: Major
      Found in test/dijkstra_test.rb and 1 other location - About 3 hrs to fix
      test/prim_test.rb on lines 41..73

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

      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

        def test_visitor
          visitor = DijkstraVisitor.new(@graph)
      
          events = []
      
      
      Severity: Major
      Found in test/prim_test.rb and 1 other location - About 3 hrs to fix
      test/dijkstra_test.rb on lines 80..112

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

      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 test_visitor has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def test_visitor
          visitor = BellmanFordVisitor.new(@graph)
      
          events = []
      
      
      Severity: Major
      Found in test/bellman_ford_test.rb - About 3 hrs to fix

        Method to_dot_graph has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_dot_graph(params = {})
              params['name'] ||= self.class.name.gsub(/:/, '_')
              fontsize       = params['fontsize'] ? params['fontsize'] : '8'
              graph          = (directed? ? DOT::Digraph : DOT::Graph).new(params)
              edge_class     = directed? ? DOT::DirectedEdge : DOT::Edge
        Severity: Minor
        Found in lib/rgl/dot.rb - 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

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

          def test_dfs_event_handlers
            expected = <<END
        tree_edge      : -1
        examine_vertex : 1
        examine_edge   : 1-2
        Severity: Major
        Found in test/traversal_test.rb and 1 other location - About 2 hrs to fix
        test/traversal_test.rb on lines 39..80

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

        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

          def test_bfs_event_handlers
            expected = <<END
        tree_edge      : -1
        examine_vertex : 1
        examine_edge   : 1-2
        Severity: Major
        Found in test/traversal_test.rb and 1 other location - About 2 hrs to fix
        test/traversal_test.rb on lines 88..129

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

        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 to_s has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

              def to_s(leader = '', indent = '    ')
                label_option = nil
        
                if @options['shape'] =~ /^M?record$/ && !@ports.empty?
                  # Ignore the given label option in this case since the ports should each
        Severity: Minor
        Found in lib/rgl/rdot.rb - 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

        Method setup has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def setup
            @dg = DirectedAdjacencyGraph.new
            @dg.add_edges([1, 2], [2, 3], [2, 4], [4, 5], [1, 6], [6, 4])
            @dg_tc = DirectedAdjacencyGraph.new
            @dg_tc.add_edges(
        Severity: Minor
        Found in test/transitivity_test.rb - About 1 hr to fix

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

          class TestDotDirectedEdge < Test::Unit::TestCase
          
            def test_0prop
              edge = DOT::DirectedEdge.new({ 'from' => 'a', 'to' => 'b' })
              dot  = edge.to_s
          Severity: Major
          Found in test/rdot_test.rb and 1 other location - About 1 hr to fix
          test/rdot_test.rb on lines 310..333

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

          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

          class TestDotEdge < Test::Unit::TestCase
          
            def test_0prop
              edge = DOT::Edge.new({ 'from' => 'a', 'to' => 'b' })
              dot  = edge.to_s
          Severity: Major
          Found in test/rdot_test.rb and 1 other location - About 1 hr to fix
          test/rdot_test.rb on lines 338..361

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

          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 test_label_quoting has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def test_label_quoting
              node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with spaces" })
              dot  = node.to_s
              assert_match(dot, /label\s*=\s*"Label with spaces"/)
          
          
          Severity: Minor
          Found in test/rdot_test.rb - About 1 hr to fix

            Method test_label_quoting has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def test_label_quoting
                node = DOT::Subgraph.new({ "name" => "test_name", "label" => "Label with spaces" })
                dot  = node.to_s
                assert_match(dot, /label\s*=\s*"Label with spaces"/)
            
            
            Severity: Minor
            Found in test/rdot_test.rb - About 1 hr to fix

              Method test_dfs_event_handlers has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def test_dfs_event_handlers
                  expected = <<END
              tree_edge      : -1
              examine_vertex : 1
              examine_edge   : 1-2
              Severity: Minor
              Found in test/traversal_test.rb - About 1 hr to fix

                Method test_label_quoting has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def test_label_quoting
                    node = DOT::Node.new({ "name" => "test_name", "label" => "Label with spaces" })
                    dot  = node.to_s
                    assert_match(dot, /label\s*=\s*"Label with spaces"/)
                
                
                Severity: Minor
                Found in test/rdot_test.rb - About 1 hr to fix

                  Method test_bfs_event_handlers has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def test_bfs_event_handlers
                      expected = <<END
                  tree_edge      : -1
                  examine_vertex : 1
                  examine_edge   : 1-2
                  Severity: Minor
                  Found in test/traversal_test.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language