prawnpdf/prawn

View on GitHub

Showing 82 of 82 total issues

Method array_from_tokens has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

        def self.array_from_tokens(tokens)
          array = []
          styles = []
          colors = []
          link = nil
Severity: Minor
Found in lib/prawn/text/formatted/parser.rb - About 7 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 Fragment has 44 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Fragment
        attr_reader :format_state, :text
        attr_writer :width
        attr_accessor :line_height, :descender, :ascender
        attr_accessor :word_spacing, :left, :baseline
Severity: Minor
Found in lib/prawn/text/formatted/fragment.rb - About 6 hrs to fix

    File box.rb has 388 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Prawn
      module Text
        module Formatted
          # @group Stable API
    
    
    Severity: Minor
    Found in lib/prawn/text/formatted/box.rb - About 5 hrs to fix

      Class Document has 33 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

        Method array_from_tokens has 99 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def self.array_from_tokens(tokens)
                  array = []
                  styles = []
                  colors = []
                  link = nil
        Severity: Major
        Found in lib/prawn/text/formatted/parser.rb - About 3 hrs to fix

          Method to_string has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

                  def self.to_string(array)
                    prefixes = {
                      bold: '<b>',
                      italic: '<i>',
                      underline: '<u>',
          Severity: Minor
          Found in lib/prawn/text/formatted/parser.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

          Class BoundingBox has 31 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class BoundingBox
                def initialize(document, parent, point, options = {}) # @private
                  unless options[:width]
                    raise ArgumentError, 'BoundingBox needs the :width option to be set'
                  end
          Severity: Minor
          Found in lib/prawn/document/bounding_box.rb - About 3 hrs to fix

            Class Box has 31 methods (exceeds 20 allowed). Consider refactoring.
            Open

                  class Box
                    include Prawn::Text::Formatted::Wrap
            
                    # @group Experimental API
            
            
            Severity: Minor
            Found in lib/prawn/text/formatted/box.rb - About 3 hrs to fix

              Class LineWrap has 29 methods (exceeds 20 allowed). Consider refactoring.
              Open

                    class LineWrap #:nodoc:
                      # The width of the last wrapped line
                      #
                      def width
                        @accumulated_width || 0
              Severity: Minor
              Found in lib/prawn/text/formatted/line_wrap.rb - About 3 hrs to fix

                Class TTF has 28 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class TTF < Font
                      attr_reader :ttf, :subsets
                
                      def unicode?
                        true
                Severity: Minor
                Found in lib/prawn/font/ttf.rb - About 3 hrs to fix

                  Method build_pdf_object has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def build_pdf_object(document)
                          if compression_method != 0
                            raise Errors::UnsupportedImageType,
                              'PNG uses an unsupported compression method'
                          end
                  Severity: Major
                  Found in lib/prawn/images/png.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

                    File document.rb has 293 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 encode_text has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def encode_text(text, options = {})
                              text = text.chomp
                      
                              if options[:kerning]
                                last_subset = nil
                      Severity: Minor
                      Found in lib/prawn/font/ttf.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 add_fragment_to_line has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def add_fragment_to_line(fragment)
                                if fragment == ''
                                  true
                                elsif fragment == "\n"
                                  @newline_encountered = true
                      Severity: Minor
                      Found in lib/prawn/text/formatted/line_wrap.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 formatted_text has a Cognitive Complexity of 19 (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 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

                      Class Arranger has 23 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                            class Arranger #:nodoc:
                              attr_reader :max_line_height
                              attr_reader :max_descender
                              attr_reader :max_ascender
                              attr_reader :finalized
                      Severity: Minor
                      Found in lib/prawn/text/formatted/arranger.rb - About 2 hrs to fix

                        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

                        File arranger.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module Prawn
                          module Text
                            module Formatted #:nodoc:
                              # @private
                        
                        
                        Severity: Minor
                        Found in lib/prawn/text/formatted/arranger.rb - About 2 hrs to fix

                          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/font/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

                          Severity
                          Category
                          Status
                          Source
                          Language