prawnpdf/prawn-table

View on GitHub
lib/prawn/table.rb

Summary

Maintainability
D
1 day
Test Coverage

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

  class Table
    module Interface
      # @group Experimental API

      # Set up and draw a table on this document. A block can be given, which will
Severity: Minor
Found in lib/prawn/table.rb - About 3 hrs to fix

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

    require 'prawn'
    require_relative 'table/column_width_calculator'
    require_relative 'table/cell'
    require_relative 'table/cells'
    require_relative 'table/cell/in_table'
    Severity: Minor
    Found in lib/prawn/table.rb - About 3 hrs to fix

      Method make_cells has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_cells(data, cell_style = {})
            assert_proper_table_data(data)
      
            cells = Cells.new
      
      
      Severity: Minor
      Found in lib/prawn/table.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 make_cells has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def make_cells(data, cell_style = {})
            assert_proper_table_data(data)
      
            cells = Cells.new
      
      
      Severity: Minor
      Found in lib/prawn/table.rb - About 1 hr to fix

        Method column_widths has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def column_widths
              @column_widths ||= begin
                if width - cells.min_width < -Prawn::FLOAT_PRECISION
                  raise Errors::CannotFit,
                    "Table's width was set too small to contain its contents " +
        Severity: Minor
        Found in lib/prawn/table.rb - About 1 hr to fix

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

              def add_one_header_row(page_of_cells, x_offset, y, row, row_of_header=nil)
          Severity: Minor
          Found in lib/prawn/table.rb - About 35 mins to fix

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

                def initialize(data, document, options={}, &block)
                  table_opts = options.dup
                  @pdf = document
                  @cells = make_cells(data, table_opts.delete(:cell_style) || {})
                  @header = false
            Severity: Minor
            Found in lib/prawn/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

            There are no issues that match your filters.

            Category
            Status