murb/workbook

View on GitHub

Showing 1,335 of 1,335 total issues

Line is too long. [188/120]
Open

      # @param [Workbook::Format, Hash] f A Workbook::Format or hash with format-options (:font_weight, :rotation, :background_color, :number_format, :text_direction, :color, :font_family)
Severity: Minor
Found in lib/workbook/writers/xls_writer.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

  • ArgumentAlignment
  • BlockAlignment
  • BlockDelimiters
  • BlockEndNewline
  • ClosingParenthesisIndentation
  • FirstArgumentIndentation
  • FirstArrayElementIndentation
  • FirstHashElementIndentation
  • FirstParameterIndentation
  • HashAlignment
  • IndentationWidth
  • MultilineArrayLineBreaks
  • MultilineBlockLayout
  • MultilineHashBraceLayout
  • MultilineHashKeyLineBreaks
  • MultilineMethodArgumentLineBreaks
  • ParameterAlignment

Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

Example:

# bad
{foo: "0000000000", bar: "0000000000", baz: "0000000000"}

# good
{foo: "0000000000",
bar: "0000000000", baz: "0000000000"}

# good (with recommended cops enabled)
{
  foo: "0000000000",
  bar: "0000000000",
  baz: "0000000000",
}

Line is too long. [186/120]
Open

  # A table is a container of rows and keeps track of the sheet it belongs to and which row is its header. Additionally suport for CSV writing and diffing with another table is included.
Severity: Minor
Found in lib/workbook/table.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

  • ArgumentAlignment
  • BlockAlignment
  • BlockDelimiters
  • BlockEndNewline
  • ClosingParenthesisIndentation
  • FirstArgumentIndentation
  • FirstArrayElementIndentation
  • FirstHashElementIndentation
  • FirstParameterIndentation
  • HashAlignment
  • IndentationWidth
  • MultilineArrayLineBreaks
  • MultilineBlockLayout
  • MultilineHashBraceLayout
  • MultilineHashKeyLineBreaks
  • MultilineMethodArgumentLineBreaks
  • ParameterAlignment

Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

Example:

# bad
{foo: "0000000000", bar: "0000000000", baz: "0000000000"}

# good
{foo: "0000000000",
bar: "0000000000", baz: "0000000000"}

# good (with recommended cops enabled)
{
  foo: "0000000000",
  bar: "0000000000",
  baz: "0000000000",
}

Method has too many lines. [43/10]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

Example: CountAsOne: ['array', 'heredoc']

def m
  array = [       # +1
    1,
    2
  ]

  hash = {        # +3
    key: 'value'
  }

  <<~HEREDOC      # +1
    Heredoc
    content.
  HEREDOC
end               # 5 points

Method has too many lines. [36/10]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

Example: CountAsOne: ['array', 'heredoc']

def m
  array = [       # +1
    1,
    2
  ]

  hash = {        # +3
    key: 'value'
  }

  <<~HEREDOC      # +1
    Heredoc
    content.
  HEREDOC
end               # 5 points

Method has too many lines. [36/10]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

Example: CountAsOne: ['array', 'heredoc']

def m
  array = [       # +1
    1,
    2
  ]

  hash = {        # +3
    key: 'value'
  }

  <<~HEREDOC      # +1
    Heredoc
    content.
  HEREDOC
end               # 5 points

Line is too long. [171/120]
Open

    # Removes all empty lines. This function is particularly useful if you typically add lines to the end of a template-table, which sometimes has unremovable empty lines.
Severity: Minor
Found in lib/workbook/table.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

  • ArgumentAlignment
  • BlockAlignment
  • BlockDelimiters
  • BlockEndNewline
  • ClosingParenthesisIndentation
  • FirstArgumentIndentation
  • FirstArrayElementIndentation
  • FirstHashElementIndentation
  • FirstParameterIndentation
  • HashAlignment
  • IndentationWidth
  • MultilineArrayLineBreaks
  • MultilineBlockLayout
  • MultilineHashBraceLayout
  • MultilineHashKeyLineBreaks
  • MultilineMethodArgumentLineBreaks
  • ParameterAlignment

Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

Example:

# bad
{foo: "0000000000", bar: "0000000000", baz: "0000000000"}

# good
{foo: "0000000000",
bar: "0000000000", baz: "0000000000"}

# good (with recommended cops enabled)
{
  foo: "0000000000",
  bar: "0000000000",
  baz: "0000000000",
}

Line is too long. [168/120]
Open

      # @param [String] extension of the document (not required). The parser used is based on the extension of the file, this option allows you to override the default.
Severity: Minor
Found in lib/workbook/book.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

  • ArgumentAlignment
  • BlockAlignment
  • BlockDelimiters
  • BlockEndNewline
  • ClosingParenthesisIndentation
  • FirstArgumentIndentation
  • FirstArrayElementIndentation
  • FirstHashElementIndentation
  • FirstParameterIndentation
  • HashAlignment
  • IndentationWidth
  • MultilineArrayLineBreaks
  • MultilineBlockLayout
  • MultilineHashBraceLayout
  • MultilineHashKeyLineBreaks
  • MultilineMethodArgumentLineBreaks
  • ParameterAlignment

Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

Example:

# bad
{foo: "0000000000", bar: "0000000000", baz: "0000000000"}

# good
{foo: "0000000000",
bar: "0000000000", baz: "0000000000"}

# good (with recommended cops enabled)
{
  foo: "0000000000",
  bar: "0000000000",
  baz: "0000000000",
}

Method has too many lines. [30/10]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

Example: CountAsOne: ['array', 'heredoc']

def m
  array = [       # +1
    1,
    2
  ]

  hash = {        # +3
    key: 'value'
  }

  <<~HEREDOC      # +1
    Heredoc
    content.
  HEREDOC
end               # 5 points

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

    Method has too many lines. [27/10]
    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 by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

    NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

    Example: CountAsOne: ['array', 'heredoc']

    def m
      array = [       # +1
        1,
        2
      ]
    
      hash = {        # +3
        key: 'value'
      }
    
      <<~HEREDOC      # +1
        Heredoc
        content.
      HEREDOC
    end               # 5 points

    Line is too long. [159/120]
    Open

          # create an overview of the differences between itself with another 'previous' table, returns a book with a single sheet and table (containing the diffs)
    Severity: Minor
    Found in lib/workbook/modules/diff_sort.rb by rubocop

    This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

    This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

    If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

    • ArgumentAlignment
    • BlockAlignment
    • BlockDelimiters
    • BlockEndNewline
    • ClosingParenthesisIndentation
    • FirstArgumentIndentation
    • FirstArrayElementIndentation
    • FirstHashElementIndentation
    • FirstParameterIndentation
    • HashAlignment
    • IndentationWidth
    • MultilineArrayLineBreaks
    • MultilineBlockLayout
    • MultilineHashBraceLayout
    • MultilineHashKeyLineBreaks
    • MultilineMethodArgumentLineBreaks
    • ParameterAlignment

    Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

    Example:

    # bad
    {foo: "0000000000", bar: "0000000000", baz: "0000000000"}
    
    # good
    {foo: "0000000000",
    bar: "0000000000", baz: "0000000000"}
    
    # good (with recommended cops enabled)
    {
      foo: "0000000000",
      bar: "0000000000",
      baz: "0000000000",
    }

    Method has too many lines. [26/10]
    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 by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

    NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

    Example: CountAsOne: ['array', 'heredoc']

    def m
      array = [       # +1
        1,
        2
      ]
    
      hash = {        # +3
        key: 'value'
      }
    
      <<~HEREDOC      # +1
        Heredoc
        content.
      HEREDOC
    end               # 5 points

    Line is too long. [158/120]
    Open

        attr_accessor :placeholder # The placeholder attribute is used in compares (corresponds to newly created or removed lines (depending which side you're on)
    Severity: Minor
    Found in lib/workbook/row.rb by rubocop

    This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

    This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

    If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

    • ArgumentAlignment
    • BlockAlignment
    • BlockDelimiters
    • BlockEndNewline
    • ClosingParenthesisIndentation
    • FirstArgumentIndentation
    • FirstArrayElementIndentation
    • FirstHashElementIndentation
    • FirstParameterIndentation
    • HashAlignment
    • IndentationWidth
    • MultilineArrayLineBreaks
    • MultilineBlockLayout
    • MultilineHashBraceLayout
    • MultilineHashKeyLineBreaks
    • MultilineMethodArgumentLineBreaks
    • ParameterAlignment

    Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

    Example:

    # bad
    {foo: "0000000000", bar: "0000000000", baz: "0000000000"}
    
    # good
    {foo: "0000000000",
    bar: "0000000000", baz: "0000000000"}
    
    # good (with recommended cops enabled)
    {
      foo: "0000000000",
      bar: "0000000000",
      baz: "0000000000",
    }

    Method has too many lines. [25/10]
    Open

          def ms_formatting_to_strftime ms_nr_format
            ms_nr_format = num_fmt_id_to_ms_formatting(ms_nr_format) if ms_nr_format.is_a? Integer
            if ms_nr_format
              ms_nr_format = ms_nr_format.to_s.downcase
              return nil if (ms_nr_format == "general") || (ms_nr_format == "")
    Severity: Minor
    Found in lib/workbook/readers/xls_shared.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

    NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

    Example: CountAsOne: ['array', 'heredoc']

    def m
      array = [       # +1
        1,
        2
      ]
    
      hash = {        # +3
        key: 'value'
      }
    
      <<~HEREDOC      # +1
        Heredoc
        content.
      HEREDOC
    end               # 5 points

    Method has too many lines. [24/10]
    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 by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

    NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

    Example: CountAsOne: ['array', 'heredoc']

    def m
      array = [       # +1
        1,
        2
      ]
    
      hash = {        # +3
        key: 'value'
      }
    
      <<~HEREDOC      # +1
        Heredoc
        content.
      HEREDOC
    end               # 5 points

    Line is too long. [153/120]
    Open

            self[0] = Workbook::Sheet.new(csv, self, parse_cells_on_batch_creation: true, cell_parse_options: {detect_date: true}) unless sheet.has_contents?
    Severity: Minor
    Found in lib/workbook/readers/txt_reader.rb by rubocop

    This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

    This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

    If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

    • ArgumentAlignment
    • BlockAlignment
    • BlockDelimiters
    • BlockEndNewline
    • ClosingParenthesisIndentation
    • FirstArgumentIndentation
    • FirstArrayElementIndentation
    • FirstHashElementIndentation
    • FirstParameterIndentation
    • HashAlignment
    • IndentationWidth
    • MultilineArrayLineBreaks
    • MultilineBlockLayout
    • MultilineHashBraceLayout
    • MultilineHashKeyLineBreaks
    • MultilineMethodArgumentLineBreaks
    • ParameterAlignment

    Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

    Example:

    # bad
    {foo: "0000000000", bar: "0000000000", baz: "0000000000"}
    
    # good
    {foo: "0000000000",
    bar: "0000000000", baz: "0000000000"}
    
    # good (with recommended cops enabled)
    {
      foo: "0000000000",
      bar: "0000000000",
      baz: "0000000000",
    }

    Method has too many lines. [22/10]
    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 by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

    NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

    Example: CountAsOne: ['array', 'heredoc']

    def m
      array = [       # +1
        1,
        2
      ]
    
      hash = {        # +3
        key: 'value'
      }
    
      <<~HEREDOC      # +1
        Heredoc
        content.
      HEREDOC
    end               # 5 points

    Line is too long. [152/120]
    Open

                set_format_property format, :vertical_align, style.xpath("style:table-cell-properties/@style:vertical-align").to_s.gsub("automatic", "auto")
    Severity: Minor
    Found in lib/workbook/readers/ods_reader.rb by rubocop

    This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop. It also ignores a shebang line by default.

    This cop has some autocorrection capabilities. It can programmatically shorten certain long lines by inserting line breaks into expressions that can be safely split across lines. These include arrays, hashes, and method calls with argument lists.

    If autocorrection is enabled, the following Layout cops are recommended to further format the broken lines. (Many of these are enabled by default.)

    • ArgumentAlignment
    • BlockAlignment
    • BlockDelimiters
    • BlockEndNewline
    • ClosingParenthesisIndentation
    • FirstArgumentIndentation
    • FirstArrayElementIndentation
    • FirstHashElementIndentation
    • FirstParameterIndentation
    • HashAlignment
    • IndentationWidth
    • MultilineArrayLineBreaks
    • MultilineBlockLayout
    • MultilineHashBraceLayout
    • MultilineHashKeyLineBreaks
    • MultilineMethodArgumentLineBreaks
    • ParameterAlignment

    Together, these cops will pretty print hashes, arrays, method calls, etc. For example, let's say the max columns is 25:

    Example:

    # bad
    {foo: "0000000000", bar: "0000000000", baz: "0000000000"}
    
    # good
    {foo: "0000000000",
    bar: "0000000000", baz: "0000000000"}
    
    # good (with recommended cops enabled)
    {
      foo: "0000000000",
      bar: "0000000000",
      baz: "0000000000",
    }
    Severity
    Category
    Status
    Source
    Language