prawnpdf/prawn

View on GitHub
lib/prawn/text/formatted/box.rb

Summary

Maintainability
D
2 days
Test Coverage

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

      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 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 draw_fragment has 39 lines of code (exceeds 25 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 1 hr to fix

          Method shrink_to_fit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  def shrink_to_fit(text)
                    loop do
                      if @disable_wrap_by_char && @font_size > @min_font_size
                        begin
                          wrap(text)
          Severity: Minor
          Found in lib/prawn/text/formatted/box.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 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 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

          There are no issues that match your filters.

          Category
          Status