Showing 86 of 90 total issues
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)
- Read upRead up
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 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def print_line
@nothing_printed = false
printed_fragments = []
fragments_this_line = []
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]
Method mapping_spans
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def mapping_spans(mapping)
mapping
.sort
.slice_when { |a, b| (b[0] - a[0]) != 1 } # Slice at key discontinuity
.flat_map { |slice|
- Read upRead up
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 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
- Read upRead up
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 10 (exceeds 5 allowed). Consider refactoring. Open
def font_style(styles)
if styles
if styles.include?(:bold)
styles.include?(:italic) ? :bold_italic : :bold
elsif styles.include?(:italic)
- Read upRead up
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_settings
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def apply_font_settings(fragment = nil, &block)
if fragment.nil?
font = current_format_state[:font]
size = current_format_state[:size]
character_spacing = current_format_state[:character_spacing] ||
- Read upRead up
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 embed_composite_font
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def embed_composite_font(reference, font)
if font_type(font) == :unknown
raise Error, %(Composite font embedding is not uspported for font "#{font.name}.")
end
- Read upRead up
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]
- Read upRead up
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
array_content = obj.map { |e|
encrypted_pdf_object(e, key, id, gen, in_content_stream)
- Read upRead up
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 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
Method span
has 27 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?
Method analyze_glyphs_for_fallback_font_support
has 26 lines of code (exceeds 25 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
Method image_position
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def image_position(width, height, options)
options[:position] ||= :left
y =
case options[:vposition]
Method initialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(document, name, options = {})
name ||= options[:family]
unless BUILT_INS.include?(name)
raise Prawn::Errors::UnknownFont,
"#{name} (#{options[:style] || 'normal'}) is not a known font."
- Read upRead up
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 9 (exceeds 5 allowed). Consider refactoring. Open
def kern(string)
kerned = [[]]
last_byte = nil
string.each_byte do |byte|
- Read upRead up
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
)
case @align
when :left
- Read upRead up
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 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
- Read upRead up
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 embed_simple_font
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def embed_simple_font(reference, font, unicode_mapping)
if font_type(font) == :unknown
raise Error, %(Simple font embedding is not uspported for font "#{font.name}.")
end
- Read upRead up
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
- Read upRead up
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"