Method fetch_parse
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def self.fetch_parse(location)
if location.match?(%r{^http}i)
result = UserAgent.get(location)
if !result.success?
raise result.error
- 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 sync
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def sync(without_save = nil)
return if !ical_url
# only sync every 5 days
if id
- 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
File calendar.rb
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Calendar < ApplicationModel
include ChecksClientNotification
include CanUniqName
include HasEscalationCalculationImpact
Method sync
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sync(without_save = nil)
return if !ical_url
# only sync every 5 days
if id
Method fetch_parse
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.fetch_parse(location)
if location.match?(%r{^http}i)
result = UserAgent.get(location)
if !result.success?
raise result.error
Method business_hours_to_hash
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def business_hours_to_hash
business_hours
.filter { |_, value| value[:active] && value[:timeframes] }
.each_with_object({}) do |(day, meta), days_memo|
days_memo[day.to_sym] = meta[:timeframes]
- 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 public_holidays_to_array
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def public_holidays_to_array
holidays = []
public_holidays&.each do |day, meta|
next if !meta
next if !meta['active']
- 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 init_setup
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.init_setup(ip = nil)
# ignore client ip if not public ip
if ip && ip =~ %r{^(::1|127\.|10\.|172\.1[6-9]\.|172\.2[0-9]\.|172\.3[0-1]\.|192\.168\.)}
ip = nil
- 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 sync_default
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sync_default
return true if !default
Calendar.find_each do |calendar|
next if calendar.id == id
- 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 calendar
Method ensure_public_holidays_details
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ensure_public_holidays_details
# fillup feed info
before = public_holidays_was
public_holidays.each do |day, meta|
- 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"