weshatheleopard/rubyXL

View on GitHub

Showing 49 of 63 total issues

Method insert_row has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def insert_row(row_index = 0)
      validate_workbook
      ensure_cell_exists(row_index)

      old_row = new_cells = nil
Severity: Minor
Found in lib/rubyXL/convenience_methods/worksheet.rb - About 1 hr to fix

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

        def add_cell(row_index = 0, column_index = 0, data = '', formula = nil, overwrite = true)
          validate_workbook
          validate_nonnegative(row_index)
          validate_nonnegative(column_index)
          row = sheet_data.rows[row_index] || add_row(row_index)
    Severity: Minor
    Found in lib/rubyXL/worksheet.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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(*params)
          row_from = row_to = col_from = col_to = nil
    
          case params.size
          when 4 then row_from, row_to, col_from, col_to = params
    Severity: Minor
    Found in lib/rubyXL/objects/reference.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 add_cell has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def add_cell(row_index = 0, column_index = 0, data = '', formula = nil, overwrite = true)
          validate_workbook
          validate_nonnegative(row_index)
          validate_nonnegative(column_index)
          row = sheet_data.rows[row_index] || add_row(row_index)
    Severity: Minor
    Found in lib/rubyXL/worksheet.rb - About 1 hr to fix

      Method before_write_xml has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def before_write_xml # This method may need to be moved higher in the hierarchy
            first_nonempty_row = nil
            last_nonempty_row = 0
            first_nonempty_column = nil
            last_nonempty_column = 0
      Severity: Minor
      Found in lib/rubyXL/objects/worksheet.rb - About 1 hr to fix

        Method initialize has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(worksheets = [], src_file_path = nil, creator = nil, modifier = nil, created_at = nil,
                           company = '', application = APPLICATION, appversion = APPVERSION, date1904 = 0,
                           is_template = false)
        Severity: Major
        Found in lib/rubyXL/objects/workbook.rb - About 1 hr to fix

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

              def value(args = {})
                r = self.raw_value
          
                case datatype
                when RubyXL::DataType::SHARED_STRING then workbook.shared_strings_container[r.to_i].to_s
          Severity: Minor
          Found in lib/rubyXL/objects/sheet_data.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 before_write_xml has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def before_write_xml
                content_types_by_ext = {}
          
                # Collect all extensions and corresponding content types
                root.rels_hash.each_pair { |klass, objects|
          Severity: Minor
          Found in lib/rubyXL/objects/content_types.rb - About 1 hr to fix

            Method insert_column has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def insert_column(column_index = 0)
                  validate_workbook
                  ensure_cell_exists(0, column_index)
            
                  old_range = cols.get_range(column_index)
            Severity: Minor
            Found in lib/rubyXL/convenience_methods/worksheet.rb - About 1 hr to fix

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

                    def to_hls
                      hls_color = HlsColor.new
              
                      # Note that we are overriding accessors with local vars here:
                      r = self.r / 255.0
              Severity: Minor
              Found in lib/rubyXL/convenience_methods/color.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 attach_relationship has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def attach_relationship(rid, rf)
                    relationships = self.class.class_variable_get(:@@ooxml_relationships)
                    klass = rf.class
                    if relationships.has_key?(klass) then
                      accessor = relationships[klass]
              Severity: Minor
              Found in lib/rubyXL/objects/relationships.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 collect_related_objects has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def collect_related_objects
                    res = related_objects.compact # Avoid tainting +related_objects+ array
                    res.concat(generic_storage) if generic_storage
              
                    if relationship_container then
              Severity: Minor
              Found in lib/rubyXL/objects/relationships.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 validate_workbook has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_workbook
                    unless workbook.nil? || workbook.worksheets.nil?
                      workbook.worksheets.each { |sheet|
                        unless sheet.nil? || sheet.sheet_data.nil? || sheet.sheet_data[row].nil?
                          if sheet.sheet_data[row][column] == self
              Severity: Minor
              Found in lib/rubyXL/cell.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

              Consider simplifying this complex logical expression.
              Open

                    if overwrite || c.nil?
                      c = RubyXL::Cell.new
                      c.worksheet = self
                      c.row = row_index
                      c.column = column_index
              Severity: Major
              Found in lib/rubyXL/worksheet.rb - About 40 mins to fix

                Method insert_cell has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def insert_cell(row = 0, col = 0, data = nil, formula = nil, shift = nil)
                Severity: Minor
                Found in lib/rubyXL/convenience_methods/worksheet.rb - About 35 mins to fix

                  Method change_column_font has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def change_column_font(column_index, change_type, arg, font, xf)
                  Severity: Minor
                  Found in lib/rubyXL/convenience_methods/worksheet.rb - About 35 mins to fix

                    Method add_cell has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def add_cell(row_index = 0, column_index = 0, data = '', formula = nil, overwrite = true)
                    Severity: Minor
                    Found in lib/rubyXL/worksheet.rb - About 35 mins to fix

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

                          def change_column_alignment(column_index, &block)
                            validate_workbook
                            ensure_cell_exists(0, column_index)
                      
                            cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
                      Severity: Minor
                      Found in lib/rubyXL/convenience_methods/worksheet.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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def self.parse(param)
                            sheet_obj = super
                            sheet_obj.sheet_data.rows.each { |r|
                              next if r.nil?
                              r.worksheet = sheet_obj
                      Severity: Minor
                      Found in lib/rubyXL/objects/worksheet.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 get_rgb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def get_rgb(workbook)
                            if rgb then
                              return rgb
                            elsif theme then
                              theme_color = workbook.theme.get_theme_color(theme)
                      Severity: Minor
                      Found in lib/rubyXL/convenience_methods/color.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

                      Severity
                      Category
                      Status
                      Source
                      Language