honeybadger-io/heya

View on GitHub

Showing 5 of 5 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?
Severity: Minor
Found in lib/heya/campaigns/base.rb - About 1 hr to fix

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
Severity: Minor
Found in app/mailers/heya/campaign_mailer.rb - About 1 hr to fix

    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
    Severity: Minor
    Found in lib/heya/campaigns/scheduler.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in lib/heya/campaigns/scheduler.rb - About 45 mins to fix

      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
      
      
      Severity: Minor
      Found in app/models/heya/campaign_membership.rb - About 35 mins to fix

      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

      Severity
      Category
      Status
      Source
      Language