airbrake/airbrake-ruby

View on GitHub

Showing 30 of 38 total issues

File tdigest.rb has 280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rbtree'

module Airbrake
  # Ruby implementation of Ted Dunning's t-digest data structure.
  #
Severity: Minor
Found in lib/airbrake-ruby/tdigest.rb - About 2 hrs to fix

    Method percentile has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def percentile(p)
          is_array = p.is_a? Array
          p = [p] unless is_array
          p.map! do |item|
            unless (0..1).cover?(item)
    Severity: Minor
    Found in lib/airbrake-ruby/tdigest.rb - About 2 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

    Class TDigest has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class TDigest
        VERBOSE_ENCODING = 1
        SMALL_ENCODING   = 2
    
        # Centroid represents a number of data points.
    Severity: Minor
    Found in lib/airbrake-ruby/tdigest.rb - About 2 hrs to fix

      Method from_bytes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.from_bytes(bytes)
            format, compression, size = bytes.unpack('NGN')
            tdigest = new(1 / compression)
      
            start_idx = 16 # after header
      Severity: Minor
      Found in lib/airbrake-ruby/tdigest.rb - About 2 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 p_rank has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def p_rank(x)
            is_array = x.is_a? Array
            x = [x] unless is_array
      
            min = @centroids.first
      Severity: Minor
      Found in lib/airbrake-ruby/tdigest.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 from_bytes has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.from_bytes(bytes)
            format, compression, size = bytes.unpack('NGN')
            tdigest = new(1 / compression)
      
            start_idx = 16 # after header
      Severity: Minor
      Found in lib/airbrake-ruby/tdigest.rb - About 1 hr to fix

        Method _digest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _digest(x, n)
              # Use 'first' and 'last' instead of min/max because of performance reasons
              # This works because RBTree is sorted
              min = min.last if (min = @centroids.first)
              max = max.last if (max = @centroids.last)
        Severity: Minor
        Found in lib/airbrake-ruby/tdigest.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 find_from_packed_refs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def find_from_packed_refs(head)
                packed_refs_path = File.join(@git_path, 'packed-refs')
                return head unless File.exist?(packed_refs_path)
        
                File.readlines(packed_refs_path).each do |line|
        Severity: Minor
        Found in lib/airbrake-ruby/filters/git_revision_filter.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 parse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.parse(response)
              code = response.code.to_i
              body = response.body
        
              begin
        Severity: Minor
        Found in lib/airbrake-ruby/response.rb - About 1 hr to fix

          Method parse_backtrace has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def parse_backtrace(exception)
                  regexp = best_regexp_for(exception)
                  root_directory = Airbrake::Config.instance.root_directory.to_s
          
                  exception.backtrace.map.with_index do |stackframe, i|
          Severity: Minor
          Found in lib/airbrake-ruby/backtrace.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 initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(user_config = {})
                self.proxy = {}
                self.queue_size = 100
                self.workers = 1
                self.code_hunks = true
          Severity: Minor
          Found in lib/airbrake-ruby/config.rb - About 1 hr to fix

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

                def _cumulate(exact: false, force: false)
                  unless force
                    factor = if @last_cumulate == 0
                               Float::INFINITY
                             else
            Severity: Minor
            Found in lib/airbrake-ruby/tdigest.rb - About 55 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                def to_json(*_args)
                  loop do
                    begin
                      json = @payload.to_json
                    rescue *JSON_EXCEPTIONS => ex
            Severity: Minor
            Found in lib/airbrake-ruby/notice.rb - About 55 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                  def attach_repository(notice)
                    if @repository
                      notice[:context][:repository] = @repository
                      return
                    end
            Severity: Minor
            Found in lib/airbrake-ruby/filters/git_repository_filter.rb - About 55 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                  def filter_hash(hash) # rubocop:disable Metrics/AbcSize
                    return hash unless hash.is_a?(Hash)
            
                    hash_copy = hash.dup
            
            
            Severity: Minor
            Found in lib/airbrake-ruby/filters/keys_filter.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 bound_mean_cumn has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def bound_mean_cumn(cumn)
                  last_c = nil
                  bounds = []
                  @centroids.each_value do |v|
                    if v.mean_cumn == cumn
            Severity: Minor
            Found in lib/airbrake-ruby/tdigest.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call(notice)
                    return unless defined?(Gem)
            
                    notice[:errors].each do |error|
                      Gem.path.each do |gem_path|
            Severity: Minor
            Found in lib/airbrake-ruby/filters/gem_root_filter.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call(notice) # rubocop:disable Metrics/AbcSize
                    exception = notice.stash[:exception]
                    return unless exception.respond_to?(:to_airbrake)
            
                    attributes = nil
            Severity: Minor
            Found in lib/airbrake-ruby/filters/exception_attributes_filter.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_lines has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_lines(file, start_line, end_line)
                  return unless (cached_file = get_from_cache(file))
            
                  lines = {}
                  cached_file.with_index(1) do |l, i|
            Severity: Minor
            Found in lib/airbrake-ruby/code_hunk.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 find_nearest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def find_nearest(x)
                  return if size == 0
            
                  upper_key, upper = @centroids.upper_bound(x)
                  lower_key, lower = @centroids.lower_bound(x)
            Severity: Minor
            Found in lib/airbrake-ruby/tdigest.rb - About 35 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

            Severity
            Category
            Status
            Source
            Language