jaredbeck/graph_matching

View on GitHub

Showing 76 of 76 total issues

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

            self.assertEqual(maxWeightMatching([ (1,2,9), (1,3,8), (2,3,10), (1,4,5), (4,5,4), (1,6,3) ]), [ -1, 6, 3, 2, 5, 4, 1 ])
Severity: Major
Found in research/van_rantwijk/mwmatching.py and 3 other locations - About 2 hrs to fix
research/van_rantwijk/mwmatching.py on lines 894..894
research/van_rantwijk/mwmatching.py on lines 899..899
research/van_rantwijk/mwmatching.py on lines 900..900

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

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

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

            self.assertEqual(maxWeightMatching([ (1,2,9), (1,3,8), (2,3,10), (1,4,5), (4,5,3), (3,6,4) ]), [ -1, 2, 1, 6, 5, 4, 3 ])
Severity: Major
Found in research/van_rantwijk/mwmatching.py and 3 other locations - About 2 hrs to fix
research/van_rantwijk/mwmatching.py on lines 894..894
research/van_rantwijk/mwmatching.py on lines 898..898
research/van_rantwijk/mwmatching.py on lines 899..899

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

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

      def l(x, y, first, label, mate, q, visited_nodes)
        # L0. [Initialize.] Set r <- FIRST(x), s <= FIRST(y).
        # If r = s, return (no vertices can be labeled).
        # Otherwise flag r and s. (Steps L1-L2 find join by advancing
        # alternately along paths P(x) and P(y). Flags are assigned
Severity: Minor
Found in lib/graph_matching/algorithm/mcm_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 e has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def e(g)
        first = []
        label = []
        mate = []

Severity: Major
Found in lib/graph_matching/algorithm/mcm_general.rb - About 2 hrs to fix

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

                        elif label[w] == 0:
                            # w is a free vertex (or an unreached vertex inside
                            # a T-blossom) but we can not reach it yet;
                            # keep track of the least-slack edge that reaches w.
                            if bestedge[w] == -1 or kslack < slack(bestedge[w]):
    Severity: Major
    Found in research/van_rantwijk/mwmatching.py and 1 other location - About 1 hr to fix
    research/van_rantwijk/mwmatching.py on lines 720..721

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

    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 bestedge[b] == -1 or kslack < slack(bestedge[b]):
                                bestedge[b] = k
    Severity: Major
    Found in research/van_rantwijk/mwmatching.py and 1 other location - About 1 hr to fix
    research/van_rantwijk/mwmatching.py on lines 722..727

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

    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 j & 1:
                    # Start index is odd; go forward and wrap.
                    j -= len(blossomchilds[b])
                    jstep = 1
                    endptrick = 0
    Severity: Major
    Found in research/van_rantwijk/mwmatching.py and 1 other location - About 1 hr to fix
    research/van_rantwijk/mwmatching.py on lines 462..470

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

    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 i & 1:
                # Start index is odd; go forward and wrap.
                j -= len(blossomchilds[b])
                jstep = 1
                endptrick = 0
    Severity: Major
    Found in research/van_rantwijk/mwmatching.py and 1 other location - About 1 hr to fix
    research/van_rantwijk/mwmatching.py on lines 387..395

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

    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 match has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def match
            m = []
            dogs, cats = g.partition
            u = init_duals(cats, dogs)
    
    
    Severity: Minor
    Found in lib/graph_matching/algorithm/mwm_bipartite.rb - About 1 hr to fix

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

                  self.assertEqual(maxWeightMatching([ (1,2,2), (1,3,-2), (2,3,1), (2,4,-1), (3,4,-6) ], False), [ -1, 2, 1, -1, -1 ])
      Severity: Major
      Found in research/van_rantwijk/mwmatching.py and 1 other location - About 1 hr to fix
      research/van_rantwijk/mwmatching.py on lines 889..889

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

      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

                  self.assertEqual(maxWeightMatching([ (1,2,2), (1,3,-2), (2,3,1), (2,4,-1), (3,4,-6) ], True), [ -1, 3, 4, 1, 2 ])
      Severity: Major
      Found in research/van_rantwijk/mwmatching.py and 1 other location - About 1 hr to fix
      research/van_rantwijk/mwmatching.py on lines 888..888

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

      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 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 check_delta3 has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def check_delta3
                bk = nil
                bd = nil
                tbk = nil
                tbd = nil
        Severity: Minor
        Found in lib/graph_matching/algorithm/mwmg_delta_assertions.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 l has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def l(x, y, first, label, mate, q, visited_nodes)
                    # L0. [Initialize.] Set r <- FIRST(x), s <= FIRST(y).
                    # If r = s, return (no vertices can be labeled).
                    # Otherwise flag r and s. (Steps L1-L2 find join by advancing
                    # alternately along paths P(x) and P(y). Flags are assigned
            Severity: Minor
            Found in lib/graph_matching/algorithm/mcm_general.rb - About 1 hr to fix

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

                          while blossomparent[jblossoms[-1]] != -1:
                              jblossoms.append(blossomparent[jblossoms[-1]])
              Severity: Major
              Found in research/van_rantwijk/mwmatching.py and 1 other location - About 1 hr to fix
              research/van_rantwijk/mwmatching.py on lines 554..555

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

              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

                          while blossomparent[iblossoms[-1]] != -1:
                              iblossoms.append(blossomparent[iblossoms[-1]])
              Severity: Major
              Found in research/van_rantwijk/mwmatching.py and 1 other location - About 1 hr to fix
              research/van_rantwijk/mwmatching.py on lines 556..557

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

              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 match has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def match
                      u = g.partition[0]
                      m = []
              
                      loop do
              Severity: Minor
              Found in lib/graph_matching/algorithm/mcm_bipartite.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language