murb/workbook

View on GitHub

Showing 39 of 1,335 total issues

Method to_html has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def to_html options = {}
        options = {style_with_inline_css: false}.merge(options)
        builder = Nokogiri::XML::Builder.new { |doc|
          doc.table do
            doc.thead do
Severity: Minor
Found in lib/workbook/writers/html_writer.rb - About 3 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 string_optimistic_date_converter has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def string_optimistic_date_converter
        proc do |v|
          if v
            rv = v
            starts_with_nr = v[0].to_i.to_s == v[0] # it should at least start with a number...
Severity: Minor
Found in lib/workbook/modules/type_parser.rb - About 3 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

Class Row has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Row
    include Workbook::Modules::Cache
    include Enumerable
    extend Forwardable

Severity: Minor
Found in lib/workbook/row.rb - About 3 hrs to fix

    Class Table has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Table
        include Enumerable
        extend Forwardable
    
        include Workbook::Modules::TableDiffSort
    Severity: Minor
    Found in lib/workbook/table.rb - About 2 hrs to fix

      Method format_to_xls_format has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def format_to_xls_format f
              unless f.is_a? Workbook::Format
                f = Workbook::Format.new f
              end
              xlsfmt = f.return_raw_for Spreadsheet::Format
      Severity: Minor
      Found in lib/workbook/writers/xls_writer.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 parse_xlsx_cell has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_xlsx_cell cell
              type = cell.attr("t")
              format_index = cell.attr("s").to_i
              position = cell.attr("r")
              formula = cell.css("f").text
      Severity: Minor
      Found in lib/workbook/readers/xlsx_reader.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 to_xlsx has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_xlsx options = {}
              formats_to_xlsx_format
      
              book = init_xlsx_spreadsheet_template.workbook
              book.worksheets.pop(book.worksheets.count - count) if book.worksheets && (book.worksheets.count > count)
      Severity: Minor
      Found in lib/workbook/writers/xlsx_writer.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 to_xls has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_xls options = {}
              book = init_spreadsheet_template
              each_with_index do |s, si|
                xls_sheet = xls_sheet(si)
                xls_sheet.name = s.name
      Severity: Minor
      Found in lib/workbook/writers/xls_writer.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 load_xlsx has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def load_xlsx file_obj, options = {}
              file_obj = file_obj.path if file_obj.is_a? File
              sheets = {}
              shared_string_file = ""
              styles = ""
      Severity: Minor
      Found in lib/workbook/readers/xlsx_reader.rb - About 1 hr to fix

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

              def parse_xls_cell xls_cell, xls_row, ci
                rv = Workbook::Cell.new nil
                begin
                  rv = Workbook::Cell.new xls_cell
                  rv.parse!
        Severity: Minor
        Found in lib/workbook/readers/xls_reader.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 to_html has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def to_html options = {}
                options = {style_with_inline_css: false}.merge(options)
                builder = Nokogiri::XML::Builder.new { |doc|
                  doc.table do
                    doc.thead do
        Severity: Minor
        Found in lib/workbook/writers/html_writer.rb - About 1 hr to fix

          Method to_xls has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def to_xls options = {}
                  book = init_spreadsheet_template
                  each_with_index do |s, si|
                    xls_sheet = xls_sheet(si)
                    xls_sheet.name = s.name
          Severity: Minor
          Found in lib/workbook/writers/xls_writer.rb - About 1 hr to fix

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

                  def create_diff_cell(scell, ocell)
                    dcell = scell.nil? ? Workbook::Cell.new(nil) : scell
                    if scell == ocell
                      dcell.format = scell.format if scell
                    elsif scell.nil?
            Severity: Minor
            Found in lib/workbook/modules/diff_sort.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 column_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def column_type
                  return @column_type if defined?(@column_type)
                  ind = index
                  table[1..500].each do |row|
                    if row[ind]&.cell_type
            Severity: Minor
            Found in lib/workbook/column.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 parse_xlsx_cell has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def parse_xlsx_cell cell
                    type = cell.attr("t")
                    format_index = cell.attr("s").to_i
                    position = cell.attr("r")
                    formula = cell.css("f").text
            Severity: Minor
            Found in lib/workbook/readers/xlsx_reader.rb - About 1 hr to fix

              Method string_american_date_converter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def string_american_date_converter
                      proc do |v|
                        if v
                          rv = v
                          # try strptime with format 'mm/dd/yyyy'
              Severity: Minor
              Found in lib/workbook/modules/type_parser.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 load_xlsx has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def load_xlsx file_obj, options = {}
                      file_obj = file_obj.path if file_obj.is_a? File
                      sheets = {}
                      shared_string_file = ""
                      styles = ""
              Severity: Minor
              Found in lib/workbook/readers/xlsx_reader.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 value_to_sym has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def value_to_sym value
                      v = nil
                      cell_type ||= ::Workbook::Modules::Cell::CLASS_CELLTYPE_MAPPING[value.class.to_s]
                      value_to_s = value.to_s.strip.downcase
                      unless value.nil? || value_to_s == ""
              Severity: Minor
              Found in lib/workbook/cell.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 to_xlsx has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def to_xlsx options = {}
                      formats_to_xlsx_format
              
                      book = init_xlsx_spreadsheet_template.workbook
                      book.worksheets.pop(book.worksheets.count - count) if book.worksheets && (book.worksheets.count > count)
              Severity: Minor
              Found in lib/workbook/writers/xlsx_writer.rb - About 1 hr to fix

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

                      def diff other, options = {}
                        options = {sort: true, ignore_headers: false}.merge(options)
                
                        aligned = align(other, options)
                        aself = aligned[:self]
                Severity: Minor
                Found in lib/workbook/modules/diff_sort.rb - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language