Showing 14 of 18 total issues
Method reach
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.reach(year = nil, month = nil)
total_block = Proc.new { |x| x.class == Hash ? x[:actual] : x }
if year.nil? && month.nil?
# Total comes from a single cell
total = metrics_cell 'People reached', "lifetime", method(:integize)
- 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 total_costs
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.total_costs(year, month)
if year < 2015
block = Proc.new { |x| floatize(x) }
breakdown = {
variable: extract_metrics(
Method reach
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.reach(year = nil, month = nil)
total_block = Proc.new { |x| x.class == Hash ? x[:actual] : x }
if year.nil? && month.nil?
# Total comes from a single cell
total = metrics_cell 'People reached', "lifetime", method(:integize)
Method metric_with_target
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def metric_with_target name, year, month, block
location = cell_location(year, name)
return nil if location.nil? # check we have a valid ref
location['document'] ||= @@lookups['document_keys'][environment]['default']
ytd_method = location['ytd_method'] || @@lookups['default_ytd_method']
Method gender
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.gender
gender_sheet = metrics_worksheet("diversity", "Gender")
genders = {}
(3..99).each do |row|
gender = gender_sheet["C#{row}"]
Method board_ids
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def board_ids
{
2013 => {
:q1 => 'cEwY2JHh',
:q2 => 'm5Gxybf6',
Method income
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.income(year, month)
slice_by = month ? month : 12
block = Proc.new { |x| x.is_a?(Array) ? x.slice(0, slice_by).inject(0.0) { |s,v| s += floatize(v) } : floatize(x) }
if year.nil? && month.nil?
years.inject(0) do |memo, year|
- 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 people_trained
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.people_trained(year = nil, month = nil)
if year.nil? && month.nil?
metrics_cell('People trained', "lifetime", method(:integize))
else
h = {
- 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 metric_with_target
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def metric_with_target name, year, month, block
location = cell_location(year, name)
return nil if location.nil? # check we have a valid ref
location['document'] ||= @@lookups['document_keys'][environment]['default']
ytd_method = location['ytd_method'] || @@lookups['default_ytd_method']
- 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 metrics_cell
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def metrics_cell identifier, year, block, ref = "cell_ref"
location = cell_location(year, identifier)
return nil if location.nil? # check we have a valid ref
location['document'] ||= @@lookups['document_keys'][environment]['default']
multiplier = location['multiplier'] || @@lookups['default_multiplier']
- 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 bookings
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.bookings(year, month)
slice_by = month ? month : 12
block = Proc.new { |x| x.is_a?(Array) ? x.slice(0, slice_by).inject(0) { |s,v| s += integize(v) } : integize(x) }
if year.nil? && month.nil?
metrics_cell 'Total bookings', "lifetime", block
- 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 gender
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.gender
gender_sheet = metrics_worksheet("diversity", "Gender")
genders = {}
(3..99).each do |row|
gender = gender_sheet["C#{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 total_costs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.total_costs(year, month)
if year < 2015
block = Proc.new { |x| floatize(x) }
breakdown = {
variable: extract_metrics(
- 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 perform
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.perform
data = {}
coverage_sectors.each do |sector|
- 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"