Showing 6 of 6 total issues
Method add
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add(user, restart: false, concurrent: false, send_now: true)
return false unless Heya.in_segments?(user, *__segments)
membership = CampaignMembership.where(user: user, campaign_gid: gid)
if membership.exists?
- 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
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build
user = params.fetch(:user)
step = params.fetch(:step)
campaign_name = step.campaign_name.underscore
Method run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(user: nil)
Heya.campaigns.each do |campaign|
if campaign.steps.any?
Queries::OrphanedMemberships.call(campaign).update_all(step_gid: campaign.steps.first.gid)
end
Method copy_view_templates
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def copy_view_templates
return if skip_views?
selection =
if defined?(Maildown)
Method run
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def run(user: nil)
Heya.campaigns.each do |campaign|
if campaign.steps.any?
Queries::OrphanedMemberships.call(campaign).update_all(step_gid: campaign.steps.first.gid)
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 migrate_next_step!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.migrate_next_step!
find_each do |membership|
campaign = GlobalID::Locator.locate(membership.campaign_gid)
receipt = campaign && CampaignReceipt.where(user: membership.user, step_gid: campaign.steps.map(&:gid)).order("created_at desc").first
- 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"