prawnpdf/prawn

View on GitHub

Showing 71 of 71 total issues

Method array_paragraphs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def self.array_paragraphs(array) # :nodoc:
          paragraphs = []
          paragraph = []
          previous_string = "\n"
          scan_pattern = /[^\n]+|\n/
Severity: Minor
Found in lib/prawn/text/formatted/parser.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 initialize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def initialize(formatted_text, options = {})
          @inked = false
          Prawn.verify_options(valid_options, options)
          options = options.dup

Severity: Minor
Found in lib/prawn/text/formatted/box.rb - About 1 hr to fix

    Method parse_gradient_arguments has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def parse_gradient_arguments(
            *arguments, from: nil, to: nil, r1: nil, r2: nil, stops: nil,
            apply_transformations: nil
          )
    
    
    Severity: Minor
    Found in lib/prawn/graphics/patterns.rb - About 1 hr to fix

      Method soft_mask has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def soft_mask(&block)
            renderer.min_version(1.4)
      
            group_attrs = ref!(
              Type: :Group,
      Severity: Minor
      Found in lib/prawn/soft_mask.rb - About 1 hr to fix

        Method parse_gradient_arguments has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_gradient_arguments(
                *arguments, from: nil, to: nil, r1: nil, r2: nil, stops: nil,
                apply_transformations: nil
              )
        
        
        Severity: Minor
        Found in lib/prawn/graphics/patterns.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_fragment has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def draw_fragment(
                  fragment, accumulated_width = 0, line_width = 0, word_spacing = 0
                ) # :nodoc:
                  case @align
                  when :left
        Severity: Minor
        Found in lib/prawn/text/formatted/box.rb - About 1 hr to fix

          Method encrypted_pdf_object has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def encrypted_pdf_object(obj, key, id, gen, in_content_stream = false)
                case obj
                when Array
                  array_content = obj.map do |e|
                    encrypted_pdf_object(e, key, id, gen, in_content_stream)
          Severity: Minor
          Found in lib/prawn/security.rb - About 1 hr to fix

            Method initialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def initialize(data)
                    super()
                    data = StringIO.new(data.dup)
            
                    data.read(8) # Skip the default header
            Severity: Minor
            Found in lib/prawn/images/png.rb - About 1 hr to fix

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

                        def add_fragment_to_line(fragment)
                          case fragment
                          when ''
                            true
                          when "\n"
                Severity: Minor
                Found in lib/prawn/text/formatted/line_wrap.rb - About 1 hr to fix

                  Method number_pages has 34 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 =
                  Severity: Minor
                  Found in lib/prawn/document.rb - About 1 hr to fix

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

                            def shrink_to_fit(text)
                              loop do
                                if @disable_wrap_by_char && @font_size > @min_font_size
                                  begin
                                    wrap(text)
                    Severity: Minor
                    Found in lib/prawn/text/formatted/box.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 print_line has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def print_line
                              @nothing_printed = false
                              printed_fragments = []
                              fragments_this_line = []
                    
                    
                    Severity: Minor
                    Found in lib/prawn/text/formatted/wrap.rb - About 1 hr to fix

                      Method calc_image_dimensions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def calc_image_dimensions(options)
                              w = options[:width] || width
                              h = options[:height] || height
                      
                              if options[:width] && !options[:height]
                      Severity: Minor
                      Found in lib/prawn/images/image.rb - About 1 hr to fix

                        Method font_style has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                                def font_style(styles)
                                  if styles
                                    if styles.include?(:bold)
                                      styles.include?(:italic) ? :bold_italic : :bold
                                    elsif styles.include?(:italic)
                        Severity: Minor
                        Found in lib/prawn/text/formatted/box.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 wrap_line has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                                def wrap_line(options)
                                  initialize_line(options)
                        
                                  # rubocop: disable Lint/AssignmentInCondition
                                  while fragment = @arranger.next_string
                        Severity: Minor
                        Found in lib/prawn/text/formatted/line_wrap.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 kern has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def kern(string)
                                kerned = [[]]
                                last_byte = nil
                        
                                string.each_byte do |byte|
                        Severity: Minor
                        Found in lib/prawn/fonts/afm.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 calc_image_dimensions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def calc_image_dimensions(options)
                                w = options[:width] || width
                                h = options[:height] || height
                        
                                if options[:width] && !options[:height]
                        Severity: Minor
                        Found in lib/prawn/images/image.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 encrypted_pdf_object has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def encrypted_pdf_object(obj, key, id, gen, in_content_stream = false)
                              case obj
                              when Array
                                array_content = obj.map do |e|
                                  encrypted_pdf_object(e, key, id, gen, in_content_stream)
                        Severity: Minor
                        Found in lib/prawn/security.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

                        Severity
                        Category
                        Status
                        Source
                        Language