savonarola/pulse_meter_core

View on GitHub

Showing 10 of 12 total issues

Class Timeline has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Timeline < Base
      include PulseMeter::Mixins::Utils
      include PulseMeter::Sensor::TimelineReduce

      MAX_TIMESPAN_POINTS = 1000
Severity: Minor
Found in lib/pulse_meter/sensor/timeline.rb - About 2 hrs to fix

    Method dump! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

            def dump!(safe = true)
              ensure_storability!
              serialized_obj = to_yaml
              if safe
                unless redis.hsetnx(DUMP_REDIS_KEY, name, serialized_obj)
    Severity: Minor
    Found in lib/pulse_meter/mixins/dumper.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 start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def start(max_packets = nil)
          while true do
            if max_packets
              break if max_packets <= 0
              max_packets -= 1
    Severity: Minor
    Found in lib/pulse_meter/udp_server.rb - About 35 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method assert_ranged_float! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def assert_ranged_float!(options, key, from, to)
            f = options[key]
            raise ArgumentError, "#{key} should be defined" unless f
            raise ArgumentError, "#{key} should be float" unless f.respond_to?(:to_f)
            f = f.to_f
    Severity: Minor
    Found in lib/pulse_meter/mixins/utils.rb - About 35 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method assert_positive_integer! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def assert_positive_integer!(options, key, default = nil)
            value = options[key] || default
            raise ArgumentError, "#{key} should be defined" unless value
            raise ArgumentError, "#{key} should be integer" unless value.respond_to?(:to_i)
            raise ArgumentError, "#{key} should be positive" unless value.to_i > 0
    Severity: Minor
    Found in lib/pulse_meter/mixins/utils.rb - About 35 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method collect_ids_to_reduce has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def collect_ids_to_reduce(time, time_from, time_to)
            ids = []
            while (time > time_from) # go backwards
              time -= interval
              interval_id = get_interval_id(time)
    Severity: Minor
    Found in lib/pulse_meter/sensor/timeline_reduce.rb - About 35 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method create_sensor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def create_sensor(name, opts)
            sensor_type = opts.respond_to?(:sensor_type) ? opts.sensor_type : opts[:sensor_type]
            klass_s = sensor_class(sensor_type)
            klass = constantize(klass_s)
            raise ArgumentError, "#{klass_s} is not a valid class for a sensor" unless klass
    Severity: Minor
    Found in lib/pulse_meter/sensor/configuration.rb - About 35 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method drop_within has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def drop_within(from, till)
            raise ArgumentError unless from.kind_of?(Time) && till.kind_of?(Time)
            start_time, end_time = time_to_redis(from.to_i), time_to_redis(till.to_i)
            current_interval_id = get_interval_id(start_time) + interval
            keys = []
    Severity: Minor
    Found in lib/pulse_meter/sensor/timeline.rb - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def method_missing(name, *args)
            with_resque do
              name = name.to_s
              if sensors.has_key?(name)
                sensors[name].event(*args)
    Severity: Minor
    Found in lib/pulse_meter/sensor/configuration.rb - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method define_without_observer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def define_without_observer(method_owner, method, without_observer)
            if has_method?(method_owner, method)
              #for redefined methods
              unless has_method?(method_owner, without_observer)
                method_owner.send(:alias_method, without_observer, method)
    Severity: Minor
    Found in lib/pulse_meter/observer.rb - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Severity
    Category
    Status
    Source
    Language