prawnpdf/prawn

View on GitHub

Showing 79 of 81 total issues

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

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

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

Avoid too many return statements within this method.
Open

      else return 'afm'
Severity: Major
Found in lib/prawn/font.rb - About 30 mins to fix

    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

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

            def process_text(text)
              string = strip_zero_width_spaces(text)
    
              if exclude_trailing_white_space?
                string = string.rstrip
    Severity: Minor
    Found in lib/prawn/text/formatted/fragment.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 pull_preceding_fragment_to_join_this_one? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def pull_preceding_fragment_to_join_this_one?(current_fragment)
              if @fragment_output.empty? && !current_fragment.empty? &&
                  @line_contains_more_than_one_word
                unless previous_fragment_ended_with_breakable? ||
                    fragment_begins_with_breakable?(current_fragment)
    Severity: Minor
    Found in lib/prawn/text/formatted/line_wrap.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(data)
            data = StringIO.new(data.dup)
    
            data.read(8) # Skip the default header
    
    
    Severity: Minor
    Found in lib/prawn/images/png.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 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 text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def text(string, options = {})
          return false if string.nil?
    
          # we modify the options. don't change the user's hash
          options = options.dup
    Severity: Minor
    Found in lib/prawn/text.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 verify_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def verify_options(accepted, actual)
        return unless debug || $DEBUG
    
        unless (act = Set[*actual.keys]).subset?(acc = Set[*accepted])
          raise Prawn::Errors::UnknownOption,
    Severity: Minor
    Found in lib/prawn.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 font_style has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

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

          def color_type(color)
            case color
            when String
              if color =~ /\A[0-F]{6}\z/i
                :RGB
    Severity: Minor
    Found in lib/prawn/graphics/color.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