Showing 41 of 69 total issues

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

      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

        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

          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

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

                      def test_label_quoting
                        node = DOT::Graph.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 transitive_reduction has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def transitive_reduction
                            raise NotDirectedError,
                                  "transitive_reduction 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 1 hr to fix

                        Method to_dot_graph has 37 lines of code (exceeds 25 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 1 hr to fix

                          Method test_name_quoting has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def test_name_quoting
                              node = DOT::Digraph.new({ "name" => "Name with spaces" })
                              dot  = node.to_s
                              assert_match(dot, /^digraph "Name with spaces" \{$/)
                          
                          
                          Severity: Minor
                          Found in test/rdot_test.rb - About 1 hr to fix

                            Method test_name_quoting has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def test_name_quoting
                                node = DOT::Graph.new({ "name" => "Name with spaces" })
                                dot  = node.to_s
                                assert_match(dot, /^graph "Name with spaces" \{$/)
                            
                            
                            Severity: Minor
                            Found in test/rdot_test.rb - About 1 hr to fix

                              Method test_name_quoting has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def test_name_quoting
                                  node = DOT::Node.new({ "name" => "Name with spaces" })
                                  dot  = node.to_s
                                  assert_match(dot, /^"Name with spaces"$/)
                              
                              
                              Severity: Minor
                              Found in test/rdot_test.rb - About 1 hr to fix

                                Method test_name_quoting has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def test_name_quoting
                                    node = DOT::Subgraph.new({ "name" => "Name with spaces" })
                                    dot  = node.to_s
                                    assert_match(dot, /^subgraph "Name with spaces" \{$/)
                                
                                
                                Severity: Minor
                                Found in test/rdot_test.rb - About 1 hr to fix

                                  Method transitive_closure has 32 lines of code (exceeds 25 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 1 hr to fix

                                    Method transitive_reduction has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        def transitive_reduction
                                          raise NotDirectedError,
                                                "transitive_reduction 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 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language