prawnpdf/prawn

View on GitHub
lib/prawn/document.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Document has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Document
    include Prawn::Document::Internals
    include PDF::Core::Annotations
    include PDF::Core::Destinations
    include Prawn::Document::Security
Severity: Minor
Found in lib/prawn/document.rb - About 4 hrs to fix

    File document.rb has 301 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'stringio'
    
    require_relative 'document/bounding_box'
    require_relative 'document/column_box'
    require_relative 'document/internals'
    Severity: Minor
    Found in lib/prawn/document.rb - About 3 hrs to fix

      Method number_pages has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def number_pages(string, options = {})
            opts = options.dup
            start_count_at = opts.delete(:start_count_at).to_i
      
            page_filter = if opts.key?(:page_filter)
      Severity: Minor
      Found in lib/prawn/document.rb - About 3 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 start_new_page has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def start_new_page(options = {})
            last_page = state.page
            if last_page
              last_page_size = last_page.size
              last_page_layout = last_page.layout
      Severity: Minor
      Found in lib/prawn/document.rb - About 1 hr to fix

        Method start_new_page has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def start_new_page(options = {})
              last_page = state.page
              if last_page
                last_page_size = last_page.size
                last_page_layout = last_page.layout
        Severity: Minor
        Found in lib/prawn/document.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 number_pages has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def number_pages(string, options = {})
              opts = options.dup
              start_count_at = opts.delete(:start_count_at).to_i
        
              page_filter = if opts.key?(:page_filter)
        Severity: Minor
        Found in lib/prawn/document.rb - About 1 hr to fix

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

              def initialize(options = {}, &block)
                options = options.dup
          
                Prawn.verify_options VALID_OPTIONS, options
          
          
          Severity: Minor
          Found in lib/prawn/document.rb - About 45 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 use_graphic_settings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def use_graphic_settings(override_settings = false)
                set_fill_color if current_fill_color != '000000' || override_settings
                set_stroke_color if current_stroke_color != '000000' || override_settings
                write_line_width if line_width != 1 || override_settings
                write_stroke_cap_style if cap_style != :butt || override_settings
          Severity: Minor
          Found in lib/prawn/document.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