Showing 8 of 10 total issues
Method absorb_children
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def absorb_children(column_names, rollup)
@children.each do |group|
next unless can_absorb?(group)
group.skip_first_row!
- 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 data_width
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def data_width
if multibyte_count
[
name.each_char.collect{|c| c.bytesize == 1 ? 1 : 2}.inject(0, &:+),
Array(data).compact.collect(&:to_s).collect{|m| m.each_char.collect{|n| n.bytesize == 1 ? 1 : 2}.inject(0, &:+)}.max
- 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 collapse!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def collapse!
children.each(&:collapse!) # depth-first. start collapsing from the bottom and work our way up.
to_absorb = []
children.each do |group|
- 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 default_display_methods
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.default_display_methods(target)
if target.class.respond_to? :columns
if target.class.columns.first.respond_to? :name
# eg ActiveRecord
- 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 populate_row
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def populate_row(prefix, hash, target)
row = TablePrint::Row.new()
# populate a row with the columns we handle
cells = {}
- 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 option_to_column
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def option_to_column(option)
if option.is_a? Hash
name = option.keys.first
if option[name].is_a? Proc
option = {:name => name, :display_method => option[name]}
- 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
Avoid too many return
statements within this method. Open
return target.members.collect(&:to_sym) if target.is_a? Struct
Method length
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def length(str)
if TablePrint::Config.multibyte
str.each_char.collect{|c| c.bytesize == 1 ? 1 : 2}.inject(0, &:+)
else
str.length
- 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"