prawnpdf/prawn-table

View on GitHub
lib/prawn/table/column_width_calculator.rb

Summary

Maintainability
C
1 day
Test Coverage

Method aggregate_cell_values has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

      def aggregate_cell_values(row_or_column, meth, aggregate)
        values = {}

        #calculate values for all cells that do not span accross multiple cells
        #this ensures that we don't have a problem if the first line includes
Severity: Minor
Found in lib/prawn/table/column_width_calculator.rb - About 4 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 natural_widths has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def natural_widths
        #calculate natural column width for all rows that do not include a span dummy
        @cells.each do |cell|
          unless has_a_span_dummy?(cell.row)
            @widths_by_column[cell.column] =
Severity: Minor
Found in lib/prawn/table/column_width_calculator.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 aggregate_cell_values has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def aggregate_cell_values(row_or_column, meth, aggregate)
        values = {}

        #calculate values for all cells that do not span accross multiple cells
        #this ensures that we don't have a problem if the first line includes
Severity: Minor
Found in lib/prawn/table/column_width_calculator.rb - About 1 hr to fix

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

          def fill_values_if_needed(values, cell, index, meth)
            #have all spanned indices been filled with a value?
            #e.g. values[0], values[1] and values[2] don't return nil given a index of 0 and a colspan of 3
            number_of_nil_values = 0
            cell.colspan.times do |i|
    Severity: Minor
    Found in lib/prawn/table/column_width_calculator.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 natural_widths has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def natural_widths
            #calculate natural column width for all rows that do not include a span dummy
            @cells.each do |cell|
              unless has_a_span_dummy?(cell.row)
                @widths_by_column[cell.column] =
    Severity: Minor
    Found in lib/prawn/table/column_width_calculator.rb - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status