prawnpdf/prawn

View on GitHub

Showing 86 of 90 total issues

Method render has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        def render(flags = {})
          unprinted_text = []

          @document.save_font do
            @document.character_spacing(@character_spacing) do
Severity: Minor
Found in lib/prawn/text/formatted/box.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 parse_afm has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_afm(file_name)
        data = {
          glyph_widths: {},
          bounding_boxes: {},
          kern_pairs: {},
Severity: Minor
Found in lib/prawn/fonts/afm.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 to_string has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def self.to_string(array)
          prefixes = {
            bold: '<b>',
            italic: '<i>',
            underline: '<u>',
Severity: Major
Found in lib/prawn/text/formatted/parser.rb - About 2 hrs to fix

    Method embed_simple_font has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def embed_simple_font(reference, font, unicode_mapping)
            if font_type(font) == :unknown
              raise Error, %(Simple font embedding is not uspported for font "#{font.name}.")
            end
    
    
    Severity: Major
    Found in lib/prawn/fonts/ttf.rb - About 2 hrs to fix

      Method create_gradient_pattern has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def create_gradient_pattern(gradient)
              if gradient.apply_transformations.nil? &&
                  current_transformation_matrix_with_translation(0, 0) !=
                      [1, 0, 0, 1, 0, 0]
                warn(
      Severity: Major
      Found in lib/prawn/graphics/patterns.rb - About 2 hrs to fix

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

                def self.array_paragraphs(array)
                  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 formatted_text has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def formatted_text(array, options = {})
              options = inspect_options_for_text(options.dup)
        
              color = options.delete(:color)
              if color
        Severity: Minor
        Found in lib/prawn/text.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 stroke_axis has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def stroke_axis(options = {})
              options = {
                at: [0, 0],
                height: bounds.height - (options[:at] || [0, 0])[1],
                width: bounds.width - (options[:at] || [0, 0])[0],
        Severity: Minor
        Found in lib/prawn/graphics.rb - About 1 hr to fix

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

                    def parse_afm(file_name)
                      data = {
                        glyph_widths: {},
                        bounding_boxes: {},
                        kern_pairs: {},
              Severity: Minor
              Found in lib/prawn/fonts/afm.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 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 { |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 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
                              )
                                case @align
                                when :left
                      Severity: Minor
                      Found in lib/prawn/text/formatted/box.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 number_pages has 36 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)
                          
                                page_filter =
                          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
                              Severity
                              Category
                              Status
                              Source
                              Language