theodi/coopy-ruby

View on GitHub

Showing 53 of 53 total issues

Method trim_blank has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def trim_blank
      return true if (h==0)
      h_test = @height
      h_test = 3 if (h_test>=3)
      view = get_cell_view
Severity: Minor
Found in lib/coopy/simple_table.rb - About 1 hr to fix

    Method move_units has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.move_units(units)
          isrc = []
          idest = []
          len = units.length
          ltop = -1.0
    Severity: Minor
    Found in lib/coopy/mover.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 move_without_extras has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.move_without_extras(src, dest)
            return nil if (src.length!=dest.length) 
            return [] if (src.length<=1)
            
            len = src.length
      Severity: Minor
      Found in lib/coopy/mover.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 render has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def render(rows) 
              return if (rows.width==0||rows.height==0)
              render = self
              render.begin_table()
              change_row = -1
      Severity: Minor
      Found in lib/coopy/diff_render.rb - About 1 hr to fix

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

            def self.mark_spaces(sl, sr) 
                return sl if (sl==sr)
                return sl if (sl.nil? || sr.nil?)
                slc = sl.gsub(" ","")
                src = sr.gsub(" ","")
        Severity: Minor
        Found in lib/coopy/diff_render.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 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

          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

          Method mark_spaces has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.mark_spaces(sl, sr) 
                  return sl if (sl==sr)
                  return sl if (sl.nil? || sr.nil?)
                  slc = sl.gsub(" ","")
                  src = sr.gsub(" ","")
          Severity: Minor
          Found in lib/coopy/diff_render.rb - About 1 hr to fix

            Method move_units has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def self.move_units(units)
                  isrc = []
                  idest = []
                  len = units.length
                  ltop = -1.0
            Severity: Minor
            Found in lib/coopy/mover.rb - About 1 hr to fix

              Method examine_cell has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def self.examine_cell(x, y, value, vcol, vrow, vcorner, cell)  
              Severity: Major
              Found in lib/coopy/diff_render.rb - About 50 mins to fix

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

                    def has_same_columns_2(a, b)
                      if (a.width!=b.width) 
                        return false
                      end
                      if (a.height==0 || b.height==0) 
                Severity: Minor
                Found in lib/coopy/compare_table.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

                Avoid deeply nested control flow statements.
                Open

                                    if (tokens.length>=3) 
                                        ref = pretty_tokens[0]
                                        pretty_tokens[0] = mark_spaces(ref,tokens[2])
                                        pretty_tokens[2] = mark_spaces(tokens[2],ref)
                                    end
                Severity: Major
                Found in lib/coopy/diff_render.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      cell.pvalue = tokens[0] if (cell.conflicted)
                  Severity: Major
                  Found in lib/coopy/diff_render.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        offset = cell.conflicted ? 1 : 0
                    Severity: Major
                    Found in lib/coopy/diff_render.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if (tokens.length == 0)
                                              pretty_tokens = ['','']
                                          end
                      Severity: Major
                      Found in lib/coopy/diff_render.rb - About 45 mins 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 to_order has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def to_order
                                if @order_cache
                                  if @reference
                                    if !@order_cache_has_reference
                                      @order_cache = nil
                          Severity: Minor
                          Found in lib/coopy/alignment.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

                          Avoid deeply nested control flow statements.
                          Open

                                              if (part!=full) 
                                                  if (cell.value.index(full)) 
                                                      div = full
                                                      cat = "conflict"
                                                      cell.conflicted = true
                          Severity: Major
                          Found in lib/coopy/diff_render.rb - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language