veracross/data-table

View on GitHub

Showing 12 of 12 total issues

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

  class Table
    attr_reader :collection, :grouped_data, :subtotals, :totals,
                :subtotal_calculations, :total_calculations, :columns

    attr_accessor :id, :title, :css_class, :empty_text,
Severity: Minor
Found in lib/data-table/table.rb - About 5 hrs to fix

    File table.rb has 358 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module DataTable
      ##
      # Config Options
      #
      # id: the html id
    Severity: Minor
    Found in lib/data-table/table.rb - About 4 hrs to fix

      Method render_group_recursive has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def render_group_recursive(collection, index = 1, group_parent = nil, ancestors = nil)
            html = ''
            ancestors ||= []
            collection.each_pair do |group_name, group_data|
              ancestors << group_parent unless ancestors[0] == group_parent
      Severity: Minor
      Found in lib/data-table/table.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_subtotals has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def render_subtotals(group_header, _group_data = nil, ancestors = nil)
            html = ''
            path = ancestors.nil? ? [] : ancestors.dup
            path << group_header
      
      
      Severity: Minor
      Found in lib/data-table/table.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_rows has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def render_rows(collection)
            html = ''
            collection.each_with_index do |row, row_index|
              css_class = @alternate_rows && row_index.odd? ? 'alt ' : ''
              if @row_style && style = @row_style.call(row, row_index)
      Severity: Minor
      Found in lib/data-table/table.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 calculate_totals! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def calculate_totals!
            @total_calculations = []
            @totals.each_with_index do |row, index|
              next if row.nil?
      
      
      Severity: Minor
      Found in lib/data-table/table.rb - About 55 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 total_row has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def total_row(collection, column_name, function = nil, index = nil, &block)
      Severity: Minor
      Found in lib/data-table/table.rb - About 35 mins to fix

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

            def render_parent_subtotals(group_array)
              html = ''
              @parent_subtotals[group_array].each_with_index do |group, index|
                next if group.nil?
        
        
        Severity: Minor
        Found in lib/data-table/table.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 total_row has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def total_row(collection, column_name, function = nil, index = nil, &block)
              function_or_block = function || block
              f = function && block_given? ? [function, block] : function_or_block
              (0..index).each do |index|
                collection[index] = {} if collection[index].nil?
        Severity: Minor
        Found in lib/data-table/table.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

        Method render_cell has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def render_cell(cell_data, row = nil, row_index = 0, col_index = 0)
              @data_type ||= type(cell_data)
        
              html = []
              html << if @renderer && row
        Severity: Minor
        Found in lib/data-table/column.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

        Method render_data_table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def render_data_table
              html = "<table id='#{@id}' class='data_table #{@css_class}' cellspacing='0' cellpadding='0'>"
              html << "<caption>#{@title}</caption>" if @title
              html << render_data_table_header if @display_header
              if @collection.any?
        Severity: Minor
        Found in lib/data-table/table.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

        Method calculate_parent_subtotals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def calculate_parent_subtotals
              @parent_subtotals = Hash.new { |h, k| h[k] = [] }
              # Iterate over all the parent groups
              parent_groups = @groupings.slice(0, @groupings.count - 1).compact
              parent_groups.count.times do
        Severity: Minor
        Found in lib/data-table/table.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