Showing 69 of 69 total issues

Method test_cycles has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def test_cycles
    d_cycles = @dg.cycles
    assert_equal 6, d_cycles.size
    assert d_cycles.include?([6])
    assert d_cycles.include?([7])
Severity: Minor
Found in test/cycles_test.rb - About 1 hr to fix

    Method relax_edges has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def relax_edges(target = nil, break_on_target = false)
          until @queue.empty?
            u = @queue.pop
    
            break if break_on_target && u == target
    Severity: Minor
    Found in lib/rgl/dijkstra.rb - 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 to_s has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_s
            if @ports.nil? || @ports.empty?
              n = (name.nil? || name.empty?) ? '' : "<#{name}>"
              n + ((n.empty? || label.nil? || label.empty?) ? '' : ' ') + label.to_s
            else
    Severity: Minor
    Found in lib/rgl/rdot.rb - 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

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

      def setup
        @graph = AdjacencyGraph[1,2, 1,3, 2,3, 2,4, 3,4]
    
        @edge_weights = {
            [1, 2] => 10,
    Severity: Major
    Found in test/prim_test.rb and 2 other locations - About 55 mins to fix
    test/bellman_ford_test.rb on lines 10..21
    test/dijkstra_test.rb on lines 10..21

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

    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

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

      def setup
        @graph = AdjacencyGraph[1,2, 1,3, 2,3, 2,4, 3,4]
    
        @edge_weights = {
            [1, 2] => 10,
    Severity: Major
    Found in test/bellman_ford_test.rb and 2 other locations - About 55 mins to fix
    test/dijkstra_test.rb on lines 10..21
    test/prim_test.rb on lines 10..21

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

    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

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

      def setup
        @graph = AdjacencyGraph[1,2, 1,3, 2,3, 2,4, 3,4]
    
        @edge_weights = {
            [1, 2] => 10,
    Severity: Major
    Found in test/dijkstra_test.rb and 2 other locations - About 55 mins to fix
    test/bellman_ford_test.rb on lines 10..21
    test/prim_test.rb on lines 10..21

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

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

        def edges_filtered_by(&filter)
          implicit_graph do |g|
            g.adjacent_iterator do |v, b|
              self.each_adjacent(v) do |u|
                b.call(u) if filter.call(v, u)
    Severity: Minor
    Found in lib/rgl/implicit.rb - About 45 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 maximum_flow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def maximum_flow(source, sink)
          raise ArgumentError.new("source and sink can't be equal") if source == sink
    
          @flow_map = Hash.new(0)
          @residual_capacity_map = lambda { |u, v| @edge_capacities_map.edge_property(u, v) - @flow_map[[u, v]] }
    Severity: Minor
    Found in lib/rgl/edmonds_karp.rb - About 45 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 condensation_graph has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def condensation_graph
          raise NotDirectedError,
                "condensation_graph only supported for directed graphs" unless directed?
    
          # Get the component map for the strongly connected components.
    Severity: Minor
    Found in lib/rgl/condensation.rb - About 45 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 vertices_filtered_by has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def vertices_filtered_by(&filter)
          implicit_graph do |g|
            g.vertex_iterator do |b|
              self.each_vertex { |v| b.call(v) if filter.call(v) }
            end
    Severity: Minor
    Found in lib/rgl/implicit.rb - About 45 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

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

      def test_record_label_with_ports
        node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "record" })
        node.ports << DOT::Port.new(nil, "a")
        node.ports << DOT::Port.new(nil, "b")
        dot = node.to_s
    Severity: Minor
    Found in test/rdot_test.rb and 1 other location - About 40 mins to fix
    test/rdot_test.rb on lines 102..108

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

    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_Mrecord_label_with_ports
        node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "Mrecord" })
        node.ports << DOT::Port.new(nil, "a")
        node.ports << DOT::Port.new(nil, "b")
        dot = node.to_s
    Severity: Minor
    Found in test/rdot_test.rb and 1 other location - About 40 mins to fix
    test/rdot_test.rb on lines 134..140

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

    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_record_no_label_with_ports
        node = DOT::Node.new({ "name" => "test_name", "shape" => "record" })
        node.ports << DOT::Port.new(nil, "a")
        node.ports << DOT::Port.new(nil, "b")
        dot = node.to_s
    Severity: Minor
    Found in test/rdot_test.rb and 1 other location - About 35 mins to fix
    test/rdot_test.rb on lines 111..117

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

    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_Mrecord_no_label_with_ports
        node = DOT::Node.new({ "name" => "test_name", "shape" => "Mrecord" })
        node.ports << DOT::Port.new(nil, "a")
        node.ports << DOT::Port.new(nil, "b")
        dot = node.to_s
    Severity: Minor
    Found in test/rdot_test.rb and 1 other location - About 35 mins to fix
    test/rdot_test.rb on lines 143..149

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

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

        def relax_edges
          (@graph.size - 1).times do
            @graph.each_edge do |u, v|
              relax_edge(u, v)
              relax_edge(v, u) unless @graph.directed?
    Severity: Minor
    Found in lib/rgl/bellman_ford.rb - About 35 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

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

      def test_no_shape_no_label_no_ports
        node = DOT::Node.new({ "name" => "test_name" })
        node.ports << DOT::Port.new(nil, "a")
        node.ports << DOT::Port.new(nil, "b")
        dot = node.to_s
    Severity: Minor
    Found in test/rdot_test.rb and 1 other location - About 35 mins to fix
    test/rdot_test.rb on lines 161..167

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

    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_no_shape_no_label_with_ports
        node = DOT::Node.new({ "name" => "test_name" })
        node.ports << DOT::Port.new(nil, "a")
        node.ports << DOT::Port.new(nil, "b")
        dot = node.to_s
    Severity: Minor
    Found in test/rdot_test.rb and 1 other location - About 35 mins to fix
    test/rdot_test.rb on lines 152..158

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

    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 @edge_options && @edge_options[edge]
              RGL::DOT::EDGE_OPTS.each do |opt|
                if @edge_options[edge].key?(:"#{opt}")
                  each_edge_options["#{opt}"] = @edge_options[edge].fetch(:"#{opt}")
                end
    Severity: Minor
    Found in lib/rgl/dot.rb and 1 other location - About 30 mins to fix
    lib/rgl/dot.rb on lines 62..68

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

    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 @vertex_options && @vertex_options[v]
              RGL::DOT::NODE_OPTS.each do |opt|
                if @vertex_options[v].key?(:"#{opt}")
                  each_vertex_options["#{opt}"] = @vertex_options[v].fetch(:"#{opt}")
                end
    Severity: Minor
    Found in lib/rgl/dot.rb and 1 other location - About 30 mins to fix
    lib/rgl/dot.rb on lines 81..87

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

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

        def transitive_closure
          raise NotDirectedError,
                "transitive_closure only supported for directed graphs" unless directed?
    
          # Compute a condensation graph in order to hide cycles.
    Severity: Minor
    Found in lib/rgl/transitivity.rb - About 25 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

    Severity
    Category
    Status
    Source
    Language