collectiveidea/hourglass

View on GitHub

Showing 4 of 4 total issues

Method call has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def call
    context.users = load_users

    context.users.each do |user|
      if (days = user.days.where(date: context.range).to_a).any?
Severity: Minor
Found in app/interactors/generate_report.rb - About 1 hr to fix

    Method roll_up has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.roll_up(user: nil, year: 2.months.ago.year, number: 2.months.ago.month)
        if user
          unless where(user: user, number: number).exists?
            date_range = Date.new(year, number).all_month
            days = Day.where(user: user, date: date_range).to_a
    Severity: Minor
    Found in app/models/month.rb - About 1 hr to fix

      Method roll_up has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.roll_up(user: nil, year: 2.months.ago.year, number: 2.months.ago.month)
          if user
            unless where(user: user, number: number).exists?
              date_range = Date.new(year, number).all_month
              days = Day.where(user: user, date: date_range).to_a
      Severity: Minor
      Found in app/models/month.rb - About 55 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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def call
          User.active.each do |user|
            time_entries = harvest.time.all(context.date, user.harvest_id)
            client_hours, internal_hours, tracked_in_real_time = 0, 0, false
      
      
      Severity: Minor
      Found in app/interactors/fetch_daily_hours.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