TracksApp/tracks

View on GitHub
app/models/stats/actions.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Actions has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Actions
    SECONDS_PER_DAY = 86_400

    attr_reader :user

Severity: Minor
Found in app/models/stats/actions.rb - About 5 hrs to fix

    File actions.rb has 301 lines of code (exceeds 300 allowed). Consider refactoring.
    Open

    module Stats
      class Actions
        SECONDS_PER_DAY = 86_400
    
        attr_reader :user
    Severity: Minor
    Found in app/models/stats/actions.rb - About 2 hrs to fix

      Complex method Stats::Actions#done_last12months_data (37.4)
      Open

          def done_last12months_data
            # get actions created and completed in the past 12+3 months. +3 for running
            # - outermost set of entries needed for these calculations
            actions_last12months = @user.todos.created_or_completed_after(@cut_off_year_plus3).select("completed_at,created_at")
      
      
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Stats::Actions#done_last30days_data (34.1)
      Open

          def done_last30days_data
            # get actions created and completed in the past 30 days.
            @actions_done_last30days = @user.todos.completed_after(@cut_off_30days).select("completed_at")
            @actions_created_last30days = @user.todos.created_after(@cut_off_30days).select("created_at")
      
      
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Stats::Actions#visible_running_time_data (27.0)
      Open

          def visible_running_time_data
            # running means
            # - not completed (completed_at must be null)
            # visible means
            # - actions not part of a hidden project
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Stats::Actions#interpolate_avg_for_current_month refers to 'set' more than self (maybe move it to another class?)
      Open

            (set[0] * (1 / percent_of_month) + set[1] + set[2]) / 3.0
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

      Feature Envy reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

      Feature Envy also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

      Feature Envy often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

      Example

      Running Reek on:

      class Warehouse
        def sale_price(item)
          (item.price - item.rebate) * @vat
        end
      end

      would report:

      Warehouse#total_price refers to item more than self (FeatureEnvy)

      since this:

      (item.price - item.rebate)

      belongs to the Item class, not the Warehouse.

      Stats::Actions#compute_running_avg_array refers to 'upper_bound' more than self (maybe move it to another class?)
      Open

            result[upper_bound - 1] = result[upper_bound - 1] * 3 if upper_bound == set.length
            result[upper_bound - 2] = result[upper_bound - 2] * 3 / 2 if upper_bound > 1 && upper_bound == set.length
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

      Feature Envy reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

      Feature Envy also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

      Feature Envy often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

      Example

      Running Reek on:

      class Warehouse
        def sale_price(item)
          (item.price - item.rebate) * @vat
        end
      end

      would report:

      Warehouse#total_price refers to item more than self (FeatureEnvy)

      since this:

      (item.price - item.rebate)

      belongs to the Item class, not the Warehouse.

      Stats::Actions#time_of_day_all_data has approx 12 statements
      Open

          def time_of_day_all_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions has at least 39 instance variables
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Too Many Instance Variables is a special case of LargeClass.

      Example

      Given this configuration

      TooManyInstanceVariables:
        max_instance_variables: 3

      and this code:

      class TooManyInstanceVariables
        def initialize
          @arg_1 = :dummy
          @arg_2 = :dummy
          @arg_3 = :dummy
          @arg_4 = :dummy
        end
      end

      Reek would emit the following warning:

      test.rb -- 5 warnings:
        [1]:TooManyInstanceVariables has at least 4 instance variables (TooManyInstanceVariables)

      Stats::Actions#completion_time_data has approx 13 statements
      Open

          def completion_time_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#time_of_day_30days_data has approx 12 statements
      Open

          def time_of_day_30days_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#visible_running_time_data has approx 12 statements
      Open

          def visible_running_time_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#running_time_data has approx 12 statements
      Open

          def running_time_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#done_last30days_data has approx 12 statements
      Open

          def done_last30days_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#week_indexes_of has approx 7 statements
      Open

          def week_indexes_of(record)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#done_last12months_data has approx 13 statements
      Open

          def done_last12months_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#day_of_week_30days_data has approx 12 statements
      Open

          def day_of_week_30days_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#day_of_week_all_data has approx 12 statements
      Open

          def day_of_week_all_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Stats::Actions#convert_to_array contains iterators nested 2 deep
      Open

            records.each { |r| (yield r).each { |i| a[i] += 1 if a[i] } }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Nested Iterator occurs when a block contains another block.

      Example

      Given

      class Duck
        class << self
          def duck_names
            %i!tick trick track!.each do |surname|
              %i!duck!.each do |last_name|
                puts "full name is #{surname} #{last_name}"
              end
            end
          end
        end
      end

      Reek would report the following warning:

      test.rb -- 1 warning:
        [5]:Duck#duck_names contains iterators nested 2 deep (NestedIterators)

      Stats::Actions has at least 41 methods
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Too Many Methods is a special case of LargeClass.

      Example

      Given this configuration

      TooManyMethods:
        max_methods: 3

      and this code:

      class TooManyMethods
        def one; end
        def two; end
        def three; end
        def four; end
      end

      Reek would emit the following warning:

      test.rb -- 1 warning:
        [1]:TooManyMethods has at least 4 methods (TooManyMethods)

      Stats::Actions#open_per_week_data has approx 9 statements
      Open

          def open_per_week_data
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      Complex method Stats::Actions#completion_time_data (25.9)
      Open

          def completion_time_data
            @actions_completion_time = @user.todos.completed.select("completed_at, created_at").reorder("completed_at DESC")
      
            # convert to array and fill in non-existing weeks with 0
            @max_weeks = @actions_completion_time.last ? difference_in_weeks(@today, @actions_completion_time.last.completed_at) : 1
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Stats::Actions#open_per_week_data (23.6)
      Open

          def open_per_week_data
            @actions_started = @user.todos.created_after(@today - 53.weeks)
              .select("todos.created_at, todos.completed_at")
              .reorder("todos.created_at DESC")
      
      
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Stats::Actions#running_time_data (23.5)
      Open

          def running_time_data
            @actions_running_time = @user.todos.not_completed.select("created_at").reorder("created_at DESC")
      
            # convert to array and fill in non-existing weeks with 0
            @max_weeks = difference_in_weeks(@today, @actions_running_time.last.created_at)
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Stats::Actions#convert_to_array calls 'a[i]' 2 times
      Open

            records.each { |r| (yield r).each { |i| a[i] += 1 if a[i] } }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#day_of_week_all_data calls 'Array.new(7) { |i| 0 }' 2 times
      Open

            @actions_creation_day_array = Array.new(7) { |i| 0 }
            @actions_creation_day.each { |t| @actions_creation_day_array[t.created_at.wday] += 1 }
            @max = @actions_creation_day_array.max
      
            # convert to array and fill in non-existing days
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#difference_in_months calls 'date2.utc' 2 times
      Open

            return (date1.utc.year - date2.utc.year) * 12 + (date1.utc.month - date2.utc.month)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#time_of_day_30days_data calls 'Array.new(24) { |i| 0 }' 2 times
      Open

            @actions_creation_hour_array = Array.new(24) { |i| 0 }
            @actions_creation_hour.each { |r| @actions_creation_hour_array[r.created_at.hour] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_hour_array = Array.new(24) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#day_of_week_30days_data calls '@user.todos' 2 times
      Open

            @actions_creation_day = @user.todos.created_after(@cut_off_month).select("created_at")
            @actions_completion_day = @user.todos.completed_after(@cut_off_month).select("completed_at")
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#day_of_week_30days_data calls 'Array.new(7) { |i| 0 }' 2 times
      Open

            @actions_creation_day_array = Array.new(7) { |i| 0 }
            @actions_creation_day.each { |r| @actions_creation_day_array[r.created_at.wday] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_day_array = Array.new(7) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#compute_running_avg_array calls 'upper_bound - 2' 2 times
      Open

            result[upper_bound - 2] = result[upper_bound - 2] * 3 / 2 if upper_bound > 1 && upper_bound == set.length
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@actions_completion_time_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@max_weeks'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions#compute_running_avg_array calls 'upper_bound == set.length' 2 times
      Open

            result[upper_bound - 1] = result[upper_bound - 1] * 3 if upper_bound == set.length
            result[upper_bound - 2] = result[upper_bound - 2] * 3 / 2 if upper_bound > 1 && upper_bound == set.length
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@actions_completion_day'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_completion_hour'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_running_time_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_done_last12months_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_started'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions#percent_of_month calls 'Time.zone.now' 2 times
      Open

            Time.zone.now.day / Time.zone.now.end_of_month.day.to_f
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#time_of_day_all_data calls 'Array.new(24) { |i| 0 }' 2 times
      Open

            @actions_creation_hour_array = Array.new(24) { |i| 0 }
            @actions_creation_hour.each { |r| @actions_creation_hour_array[r.created_at.hour] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_hour_array = Array.new(24) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@actions_created_avg_last12months_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_created_last12months_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_created_last30days_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_done_last30days'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_creation_hour'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions#time_of_day_all_data calls '@user.todos' 2 times
      Open

            @actions_creation_hour = @user.todos.select("created_at")
            @actions_completion_hour = @user.todos.completed.select("completed_at")
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@actions_done_avg_last12months_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_done_last30days_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_completed_per_week_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_open_per_week_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions#time_of_day_30days_data calls '@user.todos' 2 times
      Open

            @actions_creation_hour = @user.todos.created_after(@cut_off_month).select("created_at")
            @actions_completion_hour = @user.todos.completed_after(@cut_off_month).select("completed_at")
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@actions_completion_time'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions has no descriptive comment
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

      Example

      Given

      class Dummy
        # Do things...
      end

      Reek would emit the following warning:

      test.rb -- 1 warning:
        [1]:Dummy has no descriptive comment (IrresponsibleModule)

      Fixing this is simple - just an explaining comment:

      # The Dummy class is responsible for ...
      class Dummy
        # Do things...
      end

      Stats::Actions assumes too much for instance variable '@actions_creation_day'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@count'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions#convert_to_cumulative_array calls 'array.size' 2 times
      Open

            a = Array.new(array.size) { |i| array[i] * 100.0 / max }
            # make cumulative
            1.upto(array.size - 1) { |i| a[i] += a[i - 1] }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#difference_in_months calls 'date1.utc' 2 times
      Open

            return (date1.utc.year - date2.utc.year) * 12 + (date1.utc.month - date2.utc.month)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@actions_creation_hour_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions#completion_time_data calls '@actions_completion_time.last' 2 times
      Open

            @max_weeks = @actions_completion_time.last ? difference_in_weeks(@today, @actions_completion_time.last.completed_at) : 1
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#day_of_week_all_data calls '@user.todos' 2 times
      Open

            @actions_creation_day = @user.todos.select("created_at")
            @actions_completion_day = @user.todos.completed.select("completed_at")
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@actions_completion_day_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions#compute_running_avg_array calls 'upper_bound - 1' 2 times
      Open

            result[upper_bound - 1] = result[upper_bound - 1] * 3 if upper_bound == set.length
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#done_last30days_data calls '@user.todos' 2 times
      Open

            @actions_done_last30days = @user.todos.completed_after(@cut_off_30days).select("completed_at")
            @actions_created_last30days = @user.todos.created_after(@cut_off_30days).select("created_at")
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#percent_of_month calls 'Time.zone' 2 times
      Open

            Time.zone.now.day / Time.zone.now.end_of_month.day.to_f
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@actions_creation_day_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_running_time'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_created_last30days'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@created_count_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions#compute_running_avg_array calls 'set.length' 2 times
      Open

            result[upper_bound - 1] = result[upper_bound - 1] * 3 if upper_bound == set.length
            result[upper_bound - 2] = result[upper_bound - 2] * 3 / 2 if upper_bound > 1 && upper_bound == set.length
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions#week_indexes_of calls 'record.completed_at' 2 times
      Open

            end_week   = record.completed_at ? difference_in_weeks(@today, record.completed_at) : 0
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      Stats::Actions assumes too much for instance variable '@cum_percent_done'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@done_count_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_completion_hour_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Stats::Actions assumes too much for instance variable '@actions_running_per_week_array'
      Open

        class Actions
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      Classes should not assume that instance variables are set or present outside of the current class definition.

      Good:

      class Foo
        def initialize
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Good as well:

      class Foo
        def foo?
          bar == :foo
        end
      
        def bar
          @bar ||= :foo
        end
      end

      Bad:

      class Foo
        def go_foo!
          @bar = :foo
        end
      
        def foo?
          @bar == :foo
        end
      end

      Example

      Running Reek on:

      class Dummy
        def test
          @ivar
        end
      end

      would report:

      [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

      Note that this example would trigger this smell warning as well:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          @omg
        end
      end

      The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

      class Parent
        attr_reader :omg
      
        def initialize(omg)
          @omg = omg
        end
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

      If you don't want to expose those methods as public API just make them private like this:

      class Parent
        def initialize(omg)
          @omg = omg
        end
      
        private
        attr_reader :omg
      end
      
      class Child < Parent
        def foo
          omg
        end
      end

      Current Support in Reek

      An instance variable must:

      • be set in the constructor
      • or be accessed through a method with lazy initialization / memoization.

      If not, Instance Variable Assumption will be reported.

      Complex method Stats::Actions#time_of_day_30days_data (22.3)
      Open

          def time_of_day_30days_data
            @actions_creation_hour = @user.todos.created_after(@cut_off_month).select("created_at")
            @actions_completion_hour = @user.todos.completed_after(@cut_off_month).select("completed_at")
      
            # convert to hash to be able to fill in non-existing days
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Stats::Actions#initialize (22.0)
      Open

          def initialize(user)
            @user = user
      
            @today = Time.zone.now.utc.beginning_of_day
            @cut_off_year = 12.months.ago.beginning_of_day
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Stats::Actions#compute_running_avg_array (21.9)
      Open

          def compute_running_avg_array(set, upper_bound)
            result = set_three_month_avg(set, upper_bound)
            result[upper_bound - 1] = result[upper_bound - 1] * 3 if upper_bound == set.length
            result[upper_bound - 2] = result[upper_bound - 2] * 3 / 2 if upper_bound > 1 && upper_bound == set.length
            result[0] = "null"
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Stats::Actions#day_of_week_30days_data (21.1)
      Open

          def day_of_week_30days_data
            @actions_creation_day = @user.todos.created_after(@cut_off_month).select("created_at")
            @actions_completion_day = @user.todos.completed_after(@cut_off_month).select("completed_at")
      
            # convert to hash to be able to fill in non-existing days
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Stats::Actions#cut_off_array doesn't depend on instance state (maybe move it to another class?)
      Open

          def cut_off_array(array, cut_off)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Stats::Actions#three_month_avg doesn't depend on instance state (maybe move it to another class?)
      Open

          def three_month_avg(set, i)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Stats::Actions#difference_in_days doesn't depend on instance state (maybe move it to another class?)
      Open

          def difference_in_days(date1, date2)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Stats::Actions#cut_off_array_with_sum doesn't depend on instance state (maybe move it to another class?)
      Open

          def cut_off_array_with_sum(array, cut_off)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Stats::Actions takes parameters ['date1', 'date2'] to 3 methods
      Open

          def difference_in_months(date1, date2)
            return (date1.utc.year - date2.utc.year) * 12 + (date1.utc.month - date2.utc.month)
          end
      
          # assumes date1 > date2
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      In general, a Data Clump occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

      The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.

      Example

      Given

      class Dummy
        def x(y1,y2); end
        def y(y1,y2); end
        def z(y1,y2); end
      end

      Reek would emit the following warning:

      test.rb -- 1 warning:
        [2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)

      A possible way to fix this problem (quoting from Martin Fowler):

      The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.

      Stats::Actions#difference_in_months doesn't depend on instance state (maybe move it to another class?)
      Open

          def difference_in_months(date1, date2)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Stats::Actions takes parameters ['array_size', 'date_method_on_todo', 'records'] to 3 methods
      Open

          def put_events_into_month_buckets(records, array_size, date_method_on_todo)
            convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))] }
          end
      
          def convert_to_days_from_today_array(records, array_size, date_method_on_todo)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      In general, a Data Clump occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

      The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.

      Example

      Given

      class Dummy
        def x(y1,y2); end
        def y(y1,y2); end
        def z(y1,y2); end
      end

      Reek would emit the following warning:

      test.rb -- 1 warning:
        [2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)

      A possible way to fix this problem (quoting from Martin Fowler):

      The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.

      Stats::Actions#convert_to_cumulative_array doesn't depend on instance state (maybe move it to another class?)
      Open

          def convert_to_cumulative_array(array, max)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Stats::Actions takes parameters ['array_size', 'records'] to 5 methods
      Open

          def put_events_into_month_buckets(records, array_size, date_method_on_todo)
            convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))] }
          end
      
          def convert_to_days_from_today_array(records, array_size, date_method_on_todo)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      In general, a Data Clump occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

      The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.

      Example

      Given

      class Dummy
        def x(y1,y2); end
        def y(y1,y2); end
        def z(y1,y2); end
      end

      Reek would emit the following warning:

      test.rb -- 1 warning:
        [2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)

      A possible way to fix this problem (quoting from Martin Fowler):

      The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.

      Stats::Actions#convert_to_array doesn't depend on instance state (maybe move it to another class?)
      Open

          def convert_to_array(records, upper_bound)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Stats::Actions#month_label doesn't depend on instance state (maybe move it to another class?)
      Open

          def month_label(i)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Stats::Actions#percent_of_month doesn't depend on instance state (maybe move it to another class?)
      Open

          def percent_of_month
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      A Utility Function is any instance method that has no dependency on the state of the instance.

      Complex method Stats::Actions#time_of_day_all_data (21.0)
      Open

          def time_of_day_all_data
            @actions_creation_hour = @user.todos.select("created_at")
            @actions_completion_hour = @user.todos.completed.select("completed_at")
      
            # convert to hash to be able to fill in non-existing days
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Stats::Actions#day_of_week_all_data (20.8)
      Open

          def day_of_week_all_data
            @actions_creation_day = @user.todos.select("created_at")
            @actions_completion_day = @user.todos.completed.select("completed_at")
      
            # convert to array and fill in non-existing days
      Severity: Minor
      Found in app/models/stats/actions.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Stats::Actions#difference_in_days has the parameter name 'date1'
      Open

          def difference_in_days(date1, date2)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_weeks_running_array has the variable name 'r'
      Open

            return convert_to_array(records, array_size) { |r| [difference_in_weeks(r.completed_at, r.created_at)] }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#difference_in_months has the parameter name 'date2'
      Open

          def difference_in_months(date1, date2)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_array has the variable name 'i'
      Open

            records.each { |r| (yield r).each { |i| a[i] += 1 if a[i] } }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_cumulative_array has the variable name 'a'
      Open

            a = Array.new(array.size) { |i| array[i] * 100.0 / max }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#set_three_month_avg has the variable name 'i'
      Open

            (0..upper_bound - 1).map { |i| three_month_avg(set, i) }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions has the variable name '@cut_off_year_plus3'
      Open

            @cut_off_year_plus3 = 15.months.ago.beginning_of_day
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_array has the variable name 'r'
      Open

            records.each { |r| (yield r).each { |i| a[i] += 1 if a[i] } }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#month_label has the parameter name 'i'
      Open

          def month_label(i)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#array_of_month_labels has the variable name 'i'
      Open

            Array.new(count) { |i| month_label(i) }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#cut_off_array_with_sum has the variable name 'a'
      Open

            a = Array.new(cut_off + 1) { |i| array[i] || 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#running_time_data has the variable name 'i'
      Open

            time_labels = Array.new(@count) { |i| "#{i}-#{i + 1}" }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#week_indexes_of has the variable name 'a'
      Open

            a = []
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#put_events_into_month_buckets has the variable name 'x'
      Open

            convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))] }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#difference_in_weeks has the parameter name 'date2'
      Open

          def difference_in_weeks(date1, date2)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#time_of_day_30days_data has the variable name 'i'
      Open

            @actions_creation_hour_array = Array.new(24) { |i| 0 }
            @actions_creation_hour.each { |r| @actions_creation_hour_array[r.created_at.hour] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_hour_array = Array.new(24) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#three_month_avg has the parameter name 'i'
      Open

          def three_month_avg(set, i)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#day_of_week_30days_data has the variable name 'i'
      Open

            @actions_creation_day_array = Array.new(7) { |i| 0 }
            @actions_creation_day.each { |r| @actions_creation_day_array[r.created_at.wday] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_day_array = Array.new(7) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#done_last30days_data has the variable name 'i'
      Open

            created_count_array = Array.new(30) { |i| @actions_created_last30days.size / 30.0 }
            done_count_array    = Array.new(30) { |i| @actions_done_last30days.size / 30.0 }
            # TODO: make the strftime i18n proof
            time_labels         = Array.new(30) { |i| I18n.l(Time.zone.now - i.days, :format => :stats) }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#time_of_day_30days_data has the variable name 'r'
      Open

            @actions_creation_hour.each { |r| @actions_creation_hour_array[r.created_at.hour] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_hour_array = Array.new(24) { |i| 0 }
            @actions_completion_hour.each { |r| @actions_completion_hour_array[r.completed_at.hour] += 1 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#visible_running_time_data has the variable name 'i'
      Open

            time_labels = Array.new(@count) { |i| "#{i}-#{i + 1}" }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#cut_off_array_with_sum has the variable name 'i'
      Open

            a = Array.new(cut_off + 1) { |i| array[i] || 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#time_of_day_all_data has the variable name 'r'
      Open

            @actions_creation_hour.each { |r| @actions_creation_hour_array[r.created_at.hour] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_hour_array = Array.new(24) { |i| 0 }
            @actions_completion_hour.each { |r| @actions_completion_hour_array[r.completed_at.hour] += 1 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_array has the variable name 'a'
      Open

            a = Array.new(upper_bound, 0)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#day_of_week_all_data has the variable name 't'
      Open

            @actions_creation_day.each { |t| @actions_creation_day_array[t.created_at.wday] += 1 }
            @max = @actions_creation_day_array.max
      
            # convert to array and fill in non-existing days
            @actions_completion_day_array = Array.new(7) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#time_of_day_all_data has the variable name 'i'
      Open

            @actions_creation_hour_array = Array.new(24) { |i| 0 }
            @actions_creation_hour.each { |r| @actions_creation_hour_array[r.created_at.hour] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_hour_array = Array.new(24) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#difference_in_weeks has the parameter name 'date1'
      Open

          def difference_in_weeks(date1, date2)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_cumulative_array has the variable name 'i'
      Open

            a = Array.new(array.size) { |i| array[i] * 100.0 / max }
            # make cumulative
            1.upto(array.size - 1) { |i| a[i] += a[i - 1] }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#day_of_week_30days_data has the variable name 'r'
      Open

            @actions_creation_day.each { |r| @actions_creation_day_array[r.created_at.wday] += 1 }
      
            # convert to hash to be able to fill in non-existing days
            @actions_completion_day_array = Array.new(7) { |i| 0 }
            @actions_completion_day.each { |r| @actions_completion_day_array[r.completed_at.wday] += 1 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#week_indexes_of has the variable name 'i'
      Open

            end_week.upto(start_week) { |i| a << i }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_weeks_from_today_array has the variable name 'r'
      Open

            return convert_to_array(records, array_size) { |r| [difference_in_weeks(@today, r.send(date_method_on_todo))] }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_weeks_running_from_today_array has the variable name 'r'
      Open

            return convert_to_array(records, array_size) { |r| week_indexes_of(r) }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#cut_off_array has the variable name 'i'
      Open

            return Array.new(cut_off) { |i| array[i] || 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#day_of_week_all_data has the variable name 'i'
      Open

            @actions_creation_day_array = Array.new(7) { |i| 0 }
            @actions_creation_day.each { |t| @actions_creation_day_array[t.created_at.wday] += 1 }
            @max = @actions_creation_day_array.max
      
            # convert to array and fill in non-existing days
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#difference_in_days has the parameter name 'date2'
      Open

          def difference_in_days(date1, date2)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#completion_time_data has the variable name 'i'
      Open

            time_labels         = Array.new(@count) { |i| "#{i}-#{i + 1}" }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#convert_to_days_from_today_array has the variable name 'r'
      Open

            return convert_to_array(records, array_size) { |r| [difference_in_days(@today, r.send(date_method_on_todo))] }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#open_per_week_data has the variable name 'i'
      Open

            time_labels = Array.new(@count + 1) { |i| "#{i}-#{i + 1}" }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#put_events_into_month_buckets has the variable name 'r'
      Open

            convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))] }
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      Stats::Actions#difference_in_months has the parameter name 'date1'
      Open

          def difference_in_months(date1, date2)
      Severity: Minor
      Found in app/models/stats/actions.rb by reek

      An Uncommunicative Parameter Name is a parameter name that doesn't communicate its intent well enough.

      Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

      FIXME found
      Open

            # FIXME: These should also be used.
      Severity: Minor
      Found in app/models/stats/actions.rb by fixme

      TODO found
      Open

            # TODO: make the strftime i18n proof
      Severity: Minor
      Found in app/models/stats/actions.rb by fixme

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

            return {
              datasets: [
                { label: I18n.t('stats.labels.created'), data: @actions_creation_hour_array },
                { label: I18n.t('stats.labels.completed'), data: @actions_completion_hour_array },
              ],
      Severity: Minor
      Found in app/models/stats/actions.rb and 1 other location - About 15 mins to fix
      app/models/stats/actions.rb on lines 305..310

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 26.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          def convert_to_array(records, upper_bound)
            a = Array.new(upper_bound, 0)
            records.each { |r| (yield r).each { |i| a[i] += 1 if a[i] } }
            a
      Severity: Minor
      Found in app/models/stats/actions.rb and 1 other location - About 15 mins to fix
      app/controllers/stats_controller.rb on lines 155..158

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 26.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

            return {
              datasets: [
                { label: I18n.t('stats.labels.created'), data: @actions_creation_hour_array },
                { label: I18n.t('stats.labels.completed'), data: @actions_completion_hour_array },
              ],
      Severity: Minor
      Found in app/models/stats/actions.rb and 1 other location - About 15 mins to fix
      app/models/stats/actions.rb on lines 284..289

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 26.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            @actions_creation_hour_array = Array.new(24) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Line is too long. [125/120]
      Open

            @actions_running_per_week_array = convert_to_weeks_from_today_array(@actions_running_time, @max_weeks + 1, :created_at)
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      Line is too long. [136/120]
      Open

                { label: I18n.t('stats.labels.month_avg_completed', :months => 3), data: @actions_done_avg_last12months_array, type: "line" },
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      Line is too long. [137/120]
      Open

                { label: I18n.t('stats.labels.month_avg_created', :months => 3), data: @actions_created_avg_last12months_array, type: "line" },
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Line is too long. [154/120]
      Open

            convert_to_array(records.select { |x| x.send(date_method_on_todo) }, array_size) { |r| [difference_in_months(@today, r.send(date_method_on_todo))] }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      Do not place comments on the same line as the end keyword.
      Open

          end # unsolved, not triggered, edge case for set.length == upper_bound + 1
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

      Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

      Example:

      # bad
      if condition
        statement
      end # end if
      
      # bad
      class X # comment
        statement
      end
      
      # bad
      def x; end # comment
      
      # good
      if condition
        statement
      end
      
      # good
      class X # :nodoc:
        y
      end

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Line is too long. [125/120]
      Open

            @actions_running_per_week_array = convert_to_weeks_from_today_array(@actions_running_time, @max_weeks + 1, :created_at)
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return convert_to_array(records, array_size) { |r| [difference_in_weeks(@today, r.send(date_method_on_todo))] }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Align .select with .todos on line 205.
      Open

              .select("todos.created_at, todos.completed_at")
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks the indentation of the method name part in method calls that span more than one line.

      Example: EnforcedStyle: aligned

      # bad
      while myvariable
      .b
        # do something
      end
      
      # good
      while myvariable
            .b
        # do something
      end
      
      # good
      Thing.a
           .b
           .c

      Example: EnforcedStyle: indented

      # good
      while myvariable
        .b
      
        # do something
      end

      Example: EnforcedStyle: indentedrelativeto_receiver

      # good
      while myvariable
              .a
              .b
      
        # do something
      end
      
      # good
      myvariable = Thing
                     .a
                     .b
                     .c

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            @actions_creation_hour_array = Array.new(24) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Line is too long. [122/120]
      Open

            actions_last12months = @user.todos.created_or_completed_after(@cut_off_year_plus3).select("completed_at,created_at")
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return a
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Align .reorder with .todos on line 174.
      Open

              .reorder("todos.created_at DESC")
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks the indentation of the method name part in method calls that span more than one line.

      Example: EnforcedStyle: aligned

      # bad
      while myvariable
      .b
        # do something
      end
      
      # good
      while myvariable
            .b
        # do something
      end
      
      # good
      Thing.a
           .b
           .c

      Example: EnforcedStyle: indented

      # good
      while myvariable
        .b
      
        # do something
      end

      Example: EnforcedStyle: indentedrelativeto_receiver

      # good
      while myvariable
              .a
              .b
      
        # do something
      end
      
      # good
      myvariable = Thing
                     .a
                     .b
                     .c

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return convert_to_array(records, array_size) { |r| [difference_in_weeks(r.completed_at, r.created_at)] }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return a
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Unused block argument - total. If it's necessary, use _ or _total as an argument name to indicate that it won't be used.
      Open

              labels: @actions_creation_hour_array.each_with_index.map { |total, hour| [hour] },
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Unused block argument - total. If it's necessary, use _ or _total as an argument name to indicate that it won't be used.
      Open

              labels: @actions_creation_hour_array.each_with_index.map { |total, hour| [hour] },
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Redundant return detected.
      Open

            return ((date1.utc.at_midnight - date2.utc.at_midnight) / SECONDS_PER_DAY).to_i
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            @actions_completion_hour_array = Array.new(24) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            @actions_completion_hour_array = Array.new(24) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Line is too long. [126/120]
      Open

            @max_weeks = @actions_completion_time.last ? difference_in_weeks(@today, @actions_completion_time.last.completed_at) : 1
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return a
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Align .select with .todos on line 174.
      Open

              .select("todos.created_at")
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks the indentation of the method name part in method calls that span more than one line.

      Example: EnforcedStyle: aligned

      # bad
      while myvariable
      .b
        # do something
      end
      
      # good
      while myvariable
            .b
        # do something
      end
      
      # good
      Thing.a
           .b
           .c

      Example: EnforcedStyle: indented

      # good
      while myvariable
        .b
      
        # do something
      end

      Example: EnforcedStyle: indentedrelativeto_receiver

      # good
      while myvariable
              .a
              .b
      
        # do something
      end
      
      # good
      myvariable = Thing
                     .a
                     .b
                     .c

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            @actions_completion_day_array = Array.new(7) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            @actions_creation_day_array = Array.new(7) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return difference_in_days(date1, date2) / 7
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Align .reorder with .todos on line 205.
      Open

              .reorder("todos.created_at DESC")
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks the indentation of the method name part in method calls that span more than one line.

      Example: EnforcedStyle: aligned

      # bad
      while myvariable
      .b
        # do something
      end
      
      # good
      while myvariable
            .b
        # do something
      end
      
      # good
      Thing.a
           .b
           .c

      Example: EnforcedStyle: indented

      # good
      while myvariable
        .b
      
        # do something
      end

      Example: EnforcedStyle: indentedrelativeto_receiver

      # good
      while myvariable
              .a
              .b
      
        # do something
      end
      
      # good
      myvariable = Thing
                     .a
                     .b
                     .c

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            @actions_completion_day_array = Array.new(7) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Redundant return detected.
      Open

            return {
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return Array.new(cut_off) { |i| array[i] || 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            created_count_array = Array.new(30) { |i| @actions_created_last30days.size / 30.0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            done_count_array    = Array.new(30) { |i| @actions_done_last30days.size / 30.0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Missing magic comment # frozen_string_literal: true.
      Open

      module Stats
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop is designed to help upgrade to Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

      Example: EnforcedStyle: when_needed (default)

      # The `when_needed` style will add the frozen string literal comment
      # to files only when the `TargetRubyVersion` is set to 2.3+.
      # bad
      module Foo
        # ...
      end
      
      # good
      # frozen_string_literal: true
      
      module Foo
        # ...
      end

      Example: EnforcedStyle: always

      # The `always` style will always add the frozen string literal comment
      # to a file, regardless of the Ruby version or if `freeze` or `<<` are
      # called on a string literal.
      # bad
      module Bar
        # ...
      end
      
      # good
      # frozen_string_literal: true
      
      module Bar
        # ...
      end

      Example: EnforcedStyle: never

      # The `never` will enforce that the frozen string literal comment does
      # not exist in a file.
      # bad
      # frozen_string_literal: true
      
      module Baz
        # ...
      end
      
      # good
      module Baz
        # ...
      end

      Redundant return detected.
      Open

            return convert_to_array(records, array_size) { |r| [difference_in_days(@today, r.send(date_method_on_todo))] }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Unused block argument - i. You can omit the argument if you don't care about it.
      Open

            @actions_creation_day_array = Array.new(7) { |i| 0 }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for unused block arguments.

      Example:

      # bad
      
      do_something do |used, unused|
        puts used
      end
      
      do_something do |bar|
        puts :foo
      end
      
      define_method(:foo) do |bar|
        puts :baz
      end

      Example:

      #good
      
      do_something do |used, _unused|
        puts used
      end
      
      do_something do
        puts :foo
      end
      
      define_method(:foo) do |_bar|
        puts :baz
      end

      Line is too long. [123/120]
      Open

            @cum_percent_done = convert_to_cumulative_array(@actions_completion_time_array, @actions_completion_time.count(:all))
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      Redundant return detected.
      Open

            return convert_to_array(records, array_size) { |r| week_indexes_of(r) }
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      Redundant return detected.
      Open

            return (date1.utc.year - date2.utc.year) * 12 + (date1.utc.month - date2.utc.month)
      Severity: Minor
      Found in app/models/stats/actions.rb by rubocop

      This cop checks for redundant return expressions.

      Example:

      def test
        return something
      end
      
      def test
        one
        two
        three
        return something
      end

      It should be extended to handle methods whose body is if/else or a case expression with a default branch.

      There are no issues that match your filters.

      Category
      Status