prawnpdf/prawn-table

View on GitHub

Showing 29 of 29 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      def max_width
        return max_width_ignoring_span if @colspan == 1

        # Sum the smallest max-width from each column in the group, including
        # myself.
Severity: Minor
Found in lib/prawn/table/cell.rb and 1 other location - About 50 mins to fix
lib/prawn/table/cell.rb on lines 68..78

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 43.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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 [] 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 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 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          def rows(row_spec)
            index_cells unless defined?(@indexed) && @indexed
            row_spec = transform_spec(row_spec, @first_row, @row_count)
            Cells.new(@rows[row_spec] ||= select { |c|
                        row_spec.respond_to?(:include?) ?
    Severity: Minor
    Found in lib/prawn/table/cells.rb and 1 other location - About 35 mins to fix
    lib/prawn/table/cells.rb on lines 79..84

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 34.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          def columns(col_spec)
            index_cells unless defined?(@indexed) && @indexed
            col_spec = transform_spec(col_spec, @first_column, @column_count)
            Cells.new(@columns[col_spec] ||= select { |c|
                        col_spec.respond_to?(:include?) ?
    Severity: Minor
    Found in lib/prawn/table/cells.rb and 1 other location - About 35 mins to fix
    lib/prawn/table/cells.rb on lines 56..61

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 34.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

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

          def self.make(pdf, content, options={})
            at = options.delete(:at) || [0, pdf.cursor]
    
            return Cell::Image.new(pdf, at, content) if content.is_a?(Hash) && content[:image]
    
    
    Severity: Minor
    Found in lib/prawn/table/cell.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