prawnpdf/prawn

View on GitHub

Showing 86 of 90 total issues

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 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(
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 font has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def font(name = nil, options = DEFAULT_OPTS)
      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 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 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 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 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

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

          def find_font(name, options = {}) # :nodoc:
            if font_families.key?(name)
              family = name
              name = font_families[name][options[:style] || :normal]
              if name.is_a?(::Hash)
      Severity: Minor
      Found in lib/prawn/font.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

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

            def permissions=(perms = {})
              @permissions ||= FULL_PERMISSIONS
              perms.each do |key, value|
                unless PERMISSIONS_BITS[key]
                  raise(
      Severity: Minor
      Found in lib/prawn/security.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

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

              def omit_trailing_whitespace_from_line_width
                @consumed.reverse_each do |hash|
                  if hash[:text] == "\n"
                    break
                  elsif hash[:text].strip.empty? && @consumed.length > 1
      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

      Method print_line has a Cognitive Complexity of 7 (exceeds 5 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 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

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

              def analyze_glyphs_for_fallback_font_support(hash)
                font_glyph_pairs = []
      
                original_font = @document.font.family
                fragment_font = hash[:font] || original_font
      Severity: Minor
      Found in lib/prawn/text/formatted/box.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

      Method initialize has a Cognitive Complexity of 7 (exceeds 5 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 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

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

            def set_gradient(type, *grad, **kwargs)
              gradient = parse_gradient_arguments(*grad, **kwargs)
      
              patterns = page.resources[:Pattern] ||= {}
      
      
      Severity: Minor
      Found in lib/prawn/graphics/patterns.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

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

            def compute_width_of(string, options = {})
              scale = (options[:size] || size) / 1000.0
              if options[:kerning]
                kern(string).reduce(0) { |s, r|
                  if r.is_a?(Numeric)
      Severity: Minor
      Found in lib/prawn/fonts/ttf.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

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

              def apply_font_size(size, styles, &block)
                if subscript?(styles) || superscript?(styles)
                  relative_size = 0.583
                  size =
                    if size.nil?
      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

      Method init_bounding_box has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def init_bounding_box(user_block, options = {})
            unless user_block
              raise ArgumentError,
                'bounding boxes require a block to be drawn within the box'
            end
      Severity: Minor
      Found in lib/prawn/document/bounding_box.rb - About 25 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 soft_mask has a Cognitive Complexity of 6 (exceeds 5 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 25 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_subsection_to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_subsection_to(title, position = :last, &block)
            @parent = items[title]
            unless @parent
              raise Prawn::Errors::UnknownOutlineTitle,
                "\n No outline item with title: '#{title}' exists in the outline tree"
      Severity: Minor
      Found in lib/prawn/outline.rb - About 25 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