prawnpdf/prawn-table

View on GitHub

Showing 21 of 29 total issues

Class Cell has 71 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Cell

      # Amount of dead space (in PDF points) inside the borders but outside the
      # content. Padding defaults to 5pt.
      #
Severity: Major
Found in lib/prawn/table/cell.rb - About 1 day to fix

    File cell.rb has 439 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'date'
    module Prawn
      class Document
    
        # @group Experimental API
    Severity: Minor
    Found in lib/prawn/table/cell.rb - About 6 hrs to fix

      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

      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 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 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 draw_borders has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def draw_borders(pt)
                    x, y = pt
            
                    @pdf.mask(:line_width, :stroke_color) do
                      @borders.each do |border|
            Severity: Minor
            Found in lib/prawn/table/cell.rb - About 1 hr to fix

              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 draw_borders has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def draw_borders(pt)
                        x, y = pt
                
                        @pdf.mask(:line_width, :stroke_color) do
                          @borders.each do |border|
                Severity: Minor
                Found in lib/prawn/table/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 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

                  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 []= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def []=(row, col, cell) # :nodoc:
                            cell.extend(Cell::InTable)
                            cell.row = row
                            cell.column = col
                    
                    
                    Severity: Minor
                    Found in lib/prawn/table/cells.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 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

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

                            def [](row, col)
                              return nil if empty?
                              index_cells unless defined?(@indexed) && @indexed
                              row_array, col_array = @rows[@first_row + row] || [], @columns[@first_column + col] || []
                              if row_array.length < col_array.length
                      Severity: Minor
                      Found in lib/prawn/table/cells.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 with_font has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def with_font
                                @pdf.save_font do
                                  options = {}
                                  options[:style] = @text_options[:style] if @text_options[:style]
                                  options[:style] ||= @pdf.font.options[:style] if @pdf.font.options[:style]
                      Severity: Minor
                      Found in lib/prawn/table/cell/text.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 transform_spec has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def transform_spec(spec, first, total)
                              case spec
                              when Range
                                transform_spec(spec.begin, first, total) ..
                                  transform_spec(spec.end, first, total)
                      Severity: Minor
                      Found in lib/prawn/table/cells.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