Showing 41 of 69 total issues

Method test_visitor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def test_visitor
    visitor = DijkstraVisitor.new(@graph)

    events = []

Severity: Minor
Found in test/dijkstra_test.rb - About 1 hr to fix

    Method test_visitor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def test_visitor
        visitor = DijkstraVisitor.new(@graph)
    
        events = []
    
    
    Severity: Minor
    Found in test/prim_test.rb - About 1 hr to fix

      Method to_s has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_s(leader = '', indent = '    ')
              hdr = leader + @dot_string + (@name.nil? ? '' : ' ' + quote_ID(@name)) + " {\n"
      
              options = @options.to_a.collect do |name, val|
                unless val.nil?
      Severity: Minor
      Found in lib/rgl/rdot.rb - About 1 hr 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 test_north_graphs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def test_north_graphs
          name, nnodes, nedges = '', 0, 0
          IO.foreach(NORTH_DIR + '/Graph.log') {
              |line|
            if /name:\s*(.*)\sformat: graphml\s+nodes: (\d+)\s+edges: (\d+)/ =~ line
      Severity: Minor
      Found in test/graph_xml_test.rb - About 1 hr 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 test_option_quoting has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Method test_option_quoting has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method test_option_quoting has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Method test_option_quoting has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

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

                def setup
                  @capacities_map = {
                      [1, 2] => 3,
                      [1, 4] => 3,
                      [2, 3] => 4,
              Severity: Minor
              Found in test/edmonds_karp_test.rb - About 1 hr to fix

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

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

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

                  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

                  Method to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def to_s(leader = '', indent = '    ')
                          stringified_options = @options.collect do |name, val|
                            unless val.nil?
                              leader + indent + "#{quote_ID(name)} = #{quote_ID(val)}"
                            end
                  Severity: Minor
                  Found in lib/rgl/rdot.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

                  Method each_connected_component has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def each_connected_component
                        raise NotUndirectedError,
                              "each_connected_component only works " +
                                  "for undirected graphs." if directed?
                  
                  
                  Severity: Minor
                  Found in lib/rgl/connected_components.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