Showing 69 of 69 total issues

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

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

                    GRAPH_OPTS = [
                      'aspect', # controls aspect ratio adjustment
                      'bgcolor', # background color for drawing, plus initial fill color
                      'center', # default: false; center draing on page
                      'clusterrank', # default: local; may be "global" or "none"
                Severity: Major
                Found in lib/rgl/rdot.rb and 1 other location - About 1 hr to fix
                lib/rgl/rdot.rb on lines 58..113

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

                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

                    EDGE_OPTS = [
                      'arrowhead', # default: normal; style of arrowhead at head end
                      'arrowsize', # default: 1.0; scaling factor for arrowheads
                      'arrowtail', # default: normal; style of arrowhead at tail end
                      'color', # default: black; edge stroke color
                Severity: Major
                Found in lib/rgl/rdot.rb and 1 other location - About 1 hr to fix
                lib/rgl/rdot.rb on lines 119..183

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

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

                  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 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 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::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::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::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 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 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
                                Severity
                                Category
                                Status
                                Source
                                Language