theodi/coopy-ruby

View on GitHub
lib/coopy/table_diff.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method hilite has a Cognitive Complexity of 402 (exceeds 5 allowed). Consider refactoring.
Open

    def hilite(output)  
      return false if (!output.is_resizable?)
      output.resize(0,0)
      output.clear

Severity: Minor
Found in lib/coopy/table_diff.rb - About 1 wk 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 hilite has 438 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def hilite(output)  
      return false if (!output.is_resizable?)
      output.resize(0,0)
      output.clear

Severity: Major
Found in lib/coopy/table_diff.rb - About 2 days to fix

    File table_diff.rb has 576 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Coopy
      class TableDiff 
    
        def initialize(align, flags) 
          @align = align # Alignment
    Severity: Major
    Found in lib/coopy/table_diff.rb - About 1 day to fix

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

          def spread_context(units, del, active) 
            if (del>0 && active != nil) 
              # forward
              mark = -del-1
              skips = 0
      Severity: Minor
      Found in lib/coopy/table_diff.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 get_separator has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_separator(t, t2, root)
            sep = root
            w = t.width
            h = t.height
            view = t.get_cell_view
      Severity: Minor
      Found in lib/coopy/table_diff.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 is_reordered has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def is_reordered(m, ct) 
            reordered = false
            l = -1
            r = -1
            (0..ct-1).each do |i|
      Severity: Minor
      Found in lib/coopy/table_diff.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 spread_context has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def spread_context(units, del, active) 
            if (del>0 && active != nil) 
              # forward
              mark = -del-1
              skips = 0
      Severity: Minor
      Found in lib/coopy/table_diff.rb - About 1 hr to fix

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

            def get_separator(t, t2, root)
              sep = root
              w = t.width
              h = t.height
              view = t.get_cell_view
        Severity: Minor
        Found in lib/coopy/table_diff.rb - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                              if (@flags.allow_update) 
                                have_addition = true
                              end
          Severity: Major
          Found in lib/coopy/table_diff.rb - About 45 mins to fix

            Method report_unit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def report_unit(unit)  
                  txt  = unit.to_s
                  reordered = false
                  if (unit.l>=0) 
                    if (unit.l<@l_prev) 
            Severity: Minor
            Found in lib/coopy/table_diff.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

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

                      if (active[i]==0||active[i]==3) 
                        if (mark-i<=del+skips) 
                          active[i] = 2
                        elsif (mark-i==del+1+skips) 
                          active[i] = 3
            Severity: Major
            Found in lib/coopy/table_diff.rb and 1 other location - About 1 hr to fix
            lib/coopy/table_diff.rb on lines 93..102

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

            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 (active[i]==0||active[i]==3) 
                        if (i-mark<=del+skips) 
                          active[i] = 2
                        elsif (i-mark==del+1+skips) 
                          active[i] = 3
            Severity: Major
            Found in lib/coopy/table_diff.rb and 1 other location - About 1 hr to fix
            lib/coopy/table_diff.rb on lines 115..124

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

            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

                    (0..h-1).each do |y|
                      (0..w-1).each do |x|
                        txt = view.to_s(t2.get_cell(x,y))
                        next if (txt.nil?)
                        while (txt.index(sep)) 
            Severity: Minor
            Found in lib/coopy/table_diff.rb and 1 other location - About 35 mins to fix
            lib/coopy/table_diff.rb on lines 14..19

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

            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

                  (0..h-1).each do |y|
                    (0..w-1).each do |x|
                      txt = view.to_s(t.get_cell(x,y))
                      next if (txt.nil?)
                      while (txt.index(sep)) 
            Severity: Minor
            Found in lib/coopy/table_diff.rb and 1 other location - About 35 mins to fix
            lib/coopy/table_diff.rb on lines 26..31

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

            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

            There are no issues that match your filters.

            Category
            Status