theodi/coopy-ruby

View on GitHub
lib/coopy/diff_render.rb

Summary

Maintainability
F
3 days
Test Coverage

Method examine_cell has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

    def self.examine_cell(x, y, value, vcol, vrow, vcorner, cell)  
        cell.category = ""
        cell.category_given_tr = ""
        cell.separator = ""
        cell.conflicted = false
Severity: Minor
Found in lib/coopy/diff_render.rb - About 7 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 examine_cell has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.examine_cell(x, y, value, vcol, vrow, vcorner, cell)  
        cell.category = ""
        cell.category_given_tr = ""
        cell.separator = ""
        cell.conflicted = false
Severity: Major
Found in lib/coopy/diff_render.rb - About 2 hrs to fix

    Method render has a Cognitive Complexity of 19 (exceeds 5 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 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

    File diff_render.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Coopy
      class DiffRender 
    
        def initialize  
            @text_to_insert = []
    Severity: Minor
    Found in lib/coopy/diff_render.rb - About 2 hrs to fix

      Method sample_css has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def sample_css() 
              return ".highlighter .add  
        background-color: #7fff7f
      end
      
      
      Severity: Minor
      Found in lib/coopy/diff_render.rb - About 1 hr to fix

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

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

                        Avoid deeply nested control flow statements.
                        Open

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

                          There are no issues that match your filters.

                          Category
                          Status