prawnpdf/prawn

View on GitHub

Showing 79 of 81 total issues

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 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 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
            '[' + 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

    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 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/font/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 print_line has 27 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 encode_text has 27 lines of code (exceeds 25 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 1 hr to fix

        Method span has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def span(width, options = {})
              Prawn.verify_options [:position], options
              original_position = y
        
              # FIXME: Any way to move this upstream?
        Severity: Minor
        Found in lib/prawn/document/span.rb - About 1 hr to fix

          Method build_pdf_object has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def build_pdf_object(document)
                  if compression_method != 0
                    raise Errors::UnsupportedImageType,
                      'PNG uses an unsupported compression method'
                  end
          Severity: Minor
          Found in lib/prawn/images/png.rb - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(document, name, options = {}) #:nodoc:
                  name ||= options[:family]
                  unless BUILT_INS.include?(name)
                    raise Prawn::Errors::UnknownFont,
                      "#{name} (#{options[:style] || 'normal'}) is not a known font."
          Severity: Minor
          Found in lib/prawn/font/afm.rb - About 55 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 draw_fragment has a Cognitive Complexity of 9 (exceeds 5 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 55 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 form_fragments_from_like_font_glyph_pairs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def form_fragments_from_like_font_glyph_pairs(font_glyph_pairs, hash)
                    fragments = []
                    fragment = nil
                    current_font = nil
          
          
          Severity: Minor
          Found in lib/prawn/text/formatted/box.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 update_last_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def update_last_string(printed, unprinted, normalized_soft_hyphen = nil)
                    return if printed.nil?
          
                    if printed.empty?
                      @consumed.pop
          Severity: Minor
          Found in lib/prawn/text/formatted/arranger.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 add_to_transformation_stack has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def add_to_transformation_stack(a, b, c, d, e, f)
          Severity: Minor
          Found in lib/prawn/transformation_stack.rb - About 45 mins to fix

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

                  def dash(length = nil, options = {})
                    return current_dash_state if length.nil?
            
                    length = Array(length)
            
            
            Severity: Minor
            Found in lib/prawn/graphics/dash.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 font has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def font(name = nil, options = {})
                  return((defined?(@font) && @font) || font('Helvetica')) if name.nil?
            
                  if state.pages.empty? && !state.page.in_stamp_stream?
                    raise Prawn::Errors::NotOnPage
            Severity: Minor
            Found in lib/prawn/font.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 create_gradient_pattern has a Cognitive Complexity of 8 (exceeds 5 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 'Gradients in Prawn 2.x and lower are not correctly positioned '\
            Severity: Minor
            Found in lib/prawn/graphics/patterns.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 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 encrypted_pdf_object has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def encrypted_pdf_object(obj, key, id, gen, in_content_stream = false)
            Severity: Minor
            Found in lib/prawn/security.rb - About 35 mins to fix

              Method apply_font_size has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def apply_font_size(size, styles)
                        if subscript?(styles) || superscript?(styles)
                          relative_size = 0.583
                          size = if size.nil?
                                   @document.font_size * relative_size
              Severity: Minor
              Found in lib/prawn/text/formatted/arranger.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

              Severity
              Category
              Status
              Source
              Language