3scale/porta

View on GitHub
app/lib/stats/storage.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method ordered_hash has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def ordered_hash(since, period, options)
      raise InvalidParameterError, "'since' should be ActiveSupport::TimeWithZone" unless ActiveSupport::TimeWithZone === since

      options.assert_valid_keys(:from, :by, :order, :limit)
      raise InvalidParameterError, "Missing parameter :from" unless options.key?(:from)
Severity: Minor
Found in app/lib/stats/storage.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method compute_timeshift_deltas has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def compute_timeshift_deltas(range, shift, granularity, prefix)
      raise InvalidParameterError, 'You do not need to call this method for UTC zone (shift == 0)' if shift == 0

      prefix = key_for(prefix) + '/hour:'
      if granularity == :month # this fixes the behaviour for yearly charts
Severity: Minor
Found in app/lib/stats/storage.rb - About 1 hr to fix

    Method ordered_hash has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def ordered_hash(since, period, options)
          raise InvalidParameterError, "'since' should be ActiveSupport::TimeWithZone" unless ActiveSupport::TimeWithZone === since
    
          options.assert_valid_keys(:from, :by, :order, :limit)
          raise InvalidParameterError, "Missing parameter :from" unless options.key?(:from)
    Severity: Minor
    Found in app/lib/stats/storage.rb - About 1 hr to fix

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

          def timeshift_values_by_deltas(shift, values, deltas, granularity)
            values = values.each.with_index
      
            # HACK!!
            # FIXME: having a different one just for months it's horrible but we'll fix it later, the days are dodgy
      Severity: Minor
      Found in app/lib/stats/storage.rb - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Stats::Storage#compute_timeshift_deltas has approx 22 statements
      Open

          def compute_timeshift_deltas(range, shift, granularity, prefix)
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#compute_timeshift_deltas has 4 parameters
      Open

          def compute_timeshift_deltas(range, shift, granularity, prefix)
      Severity: Minor
      Found in app/lib/stats/storage.rb by reek

      A Long Parameter List occurs when a method has a lot of parameters.

      Example

      Given

      class Dummy
        def long_list(foo,bar,baz,fling,flung)
          puts foo,bar,baz,fling,flung
        end
      end

      Reek would report the following warning:

      test.rb -- 1 warning:
        [2]:Dummy#long_list has 5 parameters (LongParameterList)

      A common solution to this problem would be the introduction of parameter objects.

      Stats::Storage#timeshift_values_by_deltas has 4 parameters
      Open

          def timeshift_values_by_deltas(shift, values, deltas, granularity)
      Severity: Minor
      Found in app/lib/stats/storage.rb by reek

      A Long Parameter List occurs when a method has a lot of parameters.

      Example

      Given

      class Dummy
        def long_list(foo,bar,baz,fling,flung)
          puts foo,bar,baz,fling,flung
        end
      end

      Reek would report the following warning:

      test.rb -- 1 warning:
        [2]:Dummy#long_list has 5 parameters (LongParameterList)

      A common solution to this problem would be the introduction of parameter objects.

      Stats::Storage#resum_all_value contains iterators nested 2 deep
      Open

              keys = (from..to).to_time_range.each(:hour).map do |time|
                prefix + time.to_s(:compact)
              end
      
              mget(*keys).inject(0) { |sum,v| sum + v.to_i }
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#ordered_hash has approx 19 statements
      Open

          def ordered_hash(since, period, options)
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#timeshift_values_by_deltas has approx 12 statements
      Open

          def timeshift_values_by_deltas(shift, values, deltas, granularity)
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#timeshift_values_by_deltas is controlled by argument 'granularity'
      Open

            if granularity == :month
      Severity: Minor
      Found in app/lib/stats/storage.rb by reek

      Control Parameter is a special case of Control Couple

      Example

      A simple example would be the "quoted" parameter in the following method:

      def write(quoted)
        if quoted
          write_quoted @value
        else
          write_unquoted @value
        end
      end

      Fixing those problems is out of the scope of this document but an easy solution could be to remove the "write" method alltogether and to move the calls to "writequoted" / "writeunquoted" in the initial caller of "write".

      Stats::Storage#resum_all_value has approx 9 statements
      Open

          def resum_all_value(range, granularity, prefix)
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#use_aggregated_values has approx 8 statements
      Open

          def use_aggregated_values(range, granularity, prefix)
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#keys_for_range refers to 'range' more than self (maybe move it to another class?)
      Open

              from = range.begin.to_date
              to = range.end.to_date
              Range.new(from, to).map(&transform)
            else
              benchmark "keys_for_range #{range} (#{granularity})", level: :debug do
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#compute_timeshift_deltas contains iterators nested 2 deep
      Open

                margin.map do |hour|
                  prefix_with_day + HOURS_STRINGS[hour]
                end
              end
            end
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#keys_for_range has approx 9 statements
      Open

          def keys_for_range(range, granularity, key_prefix)
      Severity: Minor
      Found in app/lib/stats/storage.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.)

      Method compute_timeshift_deltas has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_timeshift_deltas(range, shift, granularity, prefix)
            raise InvalidParameterError, 'You do not need to call this method for UTC zone (shift == 0)' if shift == 0
      
            prefix = key_for(prefix) + '/hour:'
            if granularity == :month # this fixes the behaviour for yearly charts
      Severity: Minor
      Found in app/lib/stats/storage.rb - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Stats::Storage tests 'shift > 0' at least 3 times
      Open

                if shift > 0
                  value + current_delta - next_delta
                else
                  value - current_delta + next_delta
                end
      Severity: Minor
      Found in app/lib/stats/storage.rb by reek

      Repeated Conditional is a special case of Simulated Polymorphism. Basically it means you are checking the same value throughout a single class and take decisions based on this.

      Example

      Given

      class RepeatedConditionals
        attr_accessor :switch
      
        def repeat_1
          puts "Repeat 1!" if switch
        end
      
        def repeat_2
          puts "Repeat 2!" if switch
        end
      
        def repeat_3
          puts "Repeat 3!" if switch
        end
      end

      Reek would emit the following warning:

      test.rb -- 4 warnings:
        [5, 9, 13]:RepeatedConditionals tests switch at least 3 times (RepeatedConditional)

      If you get this warning then you are probably not using the right abstraction or even more probable, missing an additional abstraction.

      Stats::Storage#timeshift_values_by_deltas calls 'i+1' 2 times
      Open

                next_delta = deltas.fetch(i+1, 0)
      
                if shift > 0
                  value + current_delta - next_delta
                else
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#timeshift_values_by_deltas calls 'values.map' 2 times
      Open

              values.map do |value, i|
                current_delta = deltas.fetch(i, 0)
                next_delta = deltas.fetch(i+1, 0)
      
                if shift > 0
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#compute_timeshift_deltas calls 'range.begin' 2 times
      Open

              beginning_of_range = range.begin.beginning_of_month
              if shift > 0
                granularity_for_iteration = :end_of_month
              else # negative time zones
                granularity_for_iteration = :month
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#timeshift_values_by_deltas calls 'deltas.fetch(i+1, 0)' 2 times
      Open

                next_delta = deltas.fetch(i+1, 0)
      
                if shift > 0
                  value + current_delta - next_delta
                else
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#ordered_hash calls 'options[:order]' 2 times
      Open

                               :order => options[:order] && options[:order].to_s.upcase,
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#ordered_hash calls 'options[:limit]' 2 times
      Open

                               :limit => options[:limit] && [0, options[:limit]],
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#compute_timeshift_deltas calls 'shift.abs' 2 times
      Open

            margin = (shift < 0) ?  (0...shift.abs) : ((24 - shift.abs)..23)
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#compute_timeshift_deltas calls 'margin.count' 2 times
      Open

            benchmark "mget #{keys.count} keys in groups of #{margin.count}", level: :debug do
              # we grabbed a list of all keys before, but when parsing the data, we must first split in groups of shifted ranges (example: days) and only then we can sum
              mget(*keys).in_groups_of(margin.count).map do |i|
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#timeshift_values_by_deltas calls 'shift > 0' 2 times
      Open

                if shift > 0
                  value + current_delta - next_delta
                else
                  value - current_delta + next_delta
                end
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#resum_all_value has the variable name 'g'
      Open

            g = granularity_to_seconds(granularity)
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#compute_timeshift_deltas has the variable name 'i'
      Open

              mget(*keys).in_groups_of(margin.count).map do |i|
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#ordered_hash has the variable name 'e'
      Open

            rescue RuntimeError => e # "no such key" for example
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#timeshift_values_by_deltas has the variable name 'i'
      Open

              values.map do |value, i|
                current_delta = deltas.fetch(i, 0)
                next_delta = deltas.fetch(i+1, 0)
      
                if shift > 0
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#granularity_to_seconds has the parameter name 'g'
      Open

          def granularity_to_seconds(g)
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#resum_all_value has the variable name 'v'
      Open

              mget(*keys).inject(0) { |sum,v| sum + v.to_i }
      Severity: Minor
      Found in app/lib/stats/storage.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::Storage#granularity_to_hours has the parameter name 'g'
      Open

          def granularity_to_hours(g)
      Severity: Minor
      Found in app/lib/stats/storage.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.

      There are no issues that match your filters.

      Category
      Status