librato/librato-metrics

View on GitHub

Showing 15 of 15 total issues

Class Client has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Client
      extend Forwardable

      def_delegator :annotator, :add, :annotate

Severity: Minor
Found in lib/librato/metrics/client.rb - About 3 hrs to fix

    Method add has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

          def add(measurements)
            measurements.each do |key, value|
              multidimensional = has_tags?
              if value.respond_to?(:each)
                validate_parameters(value)
    Severity: Minor
    Found in lib/librato/metrics/queue.rb - About 3 hrs 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 add has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def add(measurements)
            measurements.each do |metric, data|
              entry = {}
              if @prefix
                metric = "#{@prefix}.#{metric}"
    Severity: Minor
    Found in lib/librato/metrics/aggregator.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 merge! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def merge!(mergeable)
            if mergeable.respond_to?(:queued)
              to_merge = mergeable.queued
            elsif mergeable.respond_to?(:has_key?)
              to_merge = mergeable
    Severity: Minor
    Found in lib/librato/metrics/queue.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 queued has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def queued
            entries = []
            multidimensional = has_tags?
    
            @aggregated.each_value do |data|
    Severity: Minor
    Found in lib/librato/metrics/aggregator.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 add has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def add(measurements)
            measurements.each do |key, value|
              multidimensional = has_tags?
              if value.respond_to?(:each)
                validate_parameters(value)
    Severity: Minor
    Found in lib/librato/metrics/queue.rb - About 1 hr to fix

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

            def queued
              entries = []
              multidimensional = has_tags?
      
              @aggregated.each_value do |data|
      Severity: Minor
      Found in lib/librato/metrics/aggregator.rb - About 1 hr to fix

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

              def merge!(mergeable)
                if mergeable.respond_to?(:queued)
                  to_merge = mergeable.queued
                elsif mergeable.respond_to?(:has_key?)
                  to_merge = mergeable
        Severity: Minor
        Found in lib/librato/metrics/queue.rb - About 1 hr to fix

          Method add has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def add(measurements)
                  measurements.each do |metric, data|
                    entry = {}
                    if @prefix
                      metric = "#{@prefix}.#{metric}"
          Severity: Minor
          Found in lib/librato/metrics/aggregator.rb - About 1 hr to fix

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

                  def submit
                    return true if self.empty?
                    options = {per_request: @per_request}
                    if persister.persist(self.client, self.queued, options)
                      @last_submit_time = Time.now
            Severity: Minor
            Found in lib/librato/metrics/processor.rb - About 45 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                    def chunk_queued(queued, per_request)
                      return [queued] if queue_count(queued) <= per_request
                      reqs = []
                      # separate metric-containing values from global values
                      globals = fetch_globals(queued)
            Severity: Minor
            Found in lib/librato/metrics/persistence/direct.rb - About 45 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                  def get_series(metric_name, options={})
                    raise ArgumentError, ":resolution and :duration or :start_time must be set" if options.empty?
                    query = options.dup
                    if query[:start_time].respond_to?(:year)
                      query[:start_time] = query[:start_time].to_i
            Severity: Minor
            Found in lib/librato/metrics/client.rb - About 45 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                  def reconcile(measurements, val)
                    arr = val.is_a?(Hash) ? [@tags, :tags] : [@source, :source]
                    return measurements if !val || val == arr.first
                    measurements.map! do |measurement|
                      unless measurement[arr.last]
            Severity: Minor
            Found in lib/librato/metrics/queue.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 persist has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def persist(client, queued, options={})
                      per_request = options[:per_request]
                      if per_request
                        requests = chunk_queued(queued, per_request)
                      else
            Severity: Minor
            Found in lib/librato/metrics/persistence/direct.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 queued has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def queued
                    return {} if @queued.empty?
                    globals = {}
                    time = has_tags? ? :time : :measure_time
                    globals[time] = @time if @time
            Severity: Minor
            Found in lib/librato/metrics/queue.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