jaredbeck/graph_matching

View on GitHub
lib/graph_matching/algorithm/mwm_general.rb

Summary

Maintainability
F
4 days
Test Coverage

File mwm_general.rb has 579 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative '../graph/weighted_graph'
require_relative '../matching'
require_relative 'matching_algorithm'

module GraphMatching
Severity: Major
Found in lib/graph_matching/algorithm/mwm_general.rb - About 1 day to fix

    Class MWMGeneral has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class MWMGeneral < MatchingAlgorithm
          # If b is a top-level blossom,
          # label[b] is 0 if b is unlabeled (free);
          #             1 if b is an S-vertex/blossom;
          #             2 if b is a T-vertex/blossom.
    Severity: Minor
    Found in lib/graph_matching/algorithm/mwm_general.rb - About 5 hrs to fix

      Method calc_delta has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

            def calc_delta(max_cardinality)
              delta = nil
              delta_type = nil
              delta_edge = nil
              delta_blossom = nil
      Severity: Minor
      Found in lib/graph_matching/algorithm/mwm_general.rb - About 4 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 add_blossom has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def add_blossom(base, k)
              v, w = @edges[k].to_a
              bb = @in_blossom[base]
              bv = @in_blossom[v]
              bw = @in_blossom[w]
      Severity: Major
      Found in lib/graph_matching/algorithm/mwm_general.rb - About 2 hrs to fix

        Method match has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

              def match(max_cardinality)
                return Matching.new if g.num_edges == 0
        
                # Iterative *stages*.  Each stage augments the matching.
                # There can be at most n stages, where n is num. vertexes.
        Severity: Minor
        Found in lib/graph_matching/algorithm/mwm_general.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 add_blossom has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_blossom(base, k)
                v, w = @edges[k].to_a
                bb = @in_blossom[base]
                bv = @in_blossom[v]
                bw = @in_blossom[w]
        Severity: Minor
        Found in lib/graph_matching/algorithm/mwm_general.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 calc_delta has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def calc_delta(max_cardinality)
                delta = nil
                delta_type = nil
                delta_edge = nil
                delta_blossom = nil
        Severity: Minor
        Found in lib/graph_matching/algorithm/mwm_general.rb - About 1 hr to fix

          Method expand_t_blossom has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def expand_t_blossom(b)
                  assert(@label_end[b]).not_nil
                  entry_child = @in_blossom[@endpoint[@label_end[b] ^ 1]]
          
                  # > Move along the blossom until we get to the base.
          Severity: Minor
          Found in lib/graph_matching/algorithm/mwm_general.rb - About 1 hr to fix

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

                  def scan_blossom(v, w)
                    # > Trace back from v and w, placing breadcrumbs as we go.
                    path = []
                    base = nil
                    until v.nil? && w.nil?
            Severity: Minor
            Found in lib/graph_matching/algorithm/mwm_general.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 scan_vertex has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def scan_vertex(v)
                    assert_label(@in_blossom[v], LBL_S)
                    augmented = false
            
                    @neighb_end[v].each do |p|
            Severity: Minor
            Found in lib/graph_matching/algorithm/mwm_general.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 augment_matching has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def augment_matching(k)
                    v, w = @edges[k].to_a
                    [[v, 2 * k + 1], [w, 2 * k]].each do |(s, p)|
                      # > Match vertex s to remote endpoint p. Then trace back from s
                      # > until we find a single vertex, swapping matched and unmatched
            Severity: Minor
            Found in lib/graph_matching/algorithm/mwm_general.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 scan_blossom has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def scan_blossom(v, w)
                    # > Trace back from v and w, placing breadcrumbs as we go.
                    path = []
                    base = nil
                    until v.nil? && w.nil?
            Severity: Minor
            Found in lib/graph_matching/algorithm/mwm_general.rb - About 1 hr to fix

              Method update_duals has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def update_duals(delta)
                      (0...@nvertex).each do |v|
                        case @label[@in_blossom[v]]
                        when LBL_S
                          @dual[v] -= delta
              Severity: Minor
              Found in lib/graph_matching/algorithm/mwm_general.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 expand_t_blossom has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def expand_t_blossom(b)
                      assert(@label_end[b]).not_nil
                      entry_child = @in_blossom[@endpoint[@label_end[b] ^ 1]]
              
                      # > Move along the blossom until we get to the base.
              Severity: Minor
              Found in lib/graph_matching/algorithm/mwm_general.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 blossom_leaves has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def blossom_leaves(b, ary = [])
                      if b < @nvertex
                        ary.push(b)
                      else
                        @blossom_children[b].each do |c|
              Severity: Minor
              Found in lib/graph_matching/algorithm/mwm_general.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 consider_tight_edge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def consider_tight_edge(k, w, p, v)
                      augmented = false
              
                      if @label[@in_blossom[w]] == LBL_FREE
              
              
              Severity: Minor
              Found in lib/graph_matching/algorithm/mwm_general.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 assign_label has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def assign_label(w, t, p = nil)
                      b = @in_blossom[w]
                      assert_label(w, LBL_FREE)
                      assert_label(b, LBL_FREE)
                      @label[w] = @label[b] = t
              Severity: Minor
              Found in lib/graph_matching/algorithm/mwm_general.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

              There are no issues that match your filters.

              Category
              Status