getsentry/raven-ruby

View on GitHub

Showing 104 of 139 total issues

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

        def self.subscribe!
          subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
            next if EXCLUDED_EVENTS.include? payload[:name]

            record_on_current_span(op: SPAN_PREFIX + event_name, start_timestamp: payload[START_TIMESTAMP_NAME], description: payload[:sql], duration: duration) do |span|
Severity: Minor
Found in sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb - About 6 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 Configuration has 42 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Configuration
    include CustomInspection
    include LoggingHelper
    include ArgumentCheckingHelper

Severity: Minor
Found in sentry-ruby/lib/sentry/configuration.rb - About 5 hrs to fix

    Class Configuration has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Configuration
        # Directories to be recognized as part of your app. e.g. if you
        # have an `engines` dir at the root of your project, you may want
        # to set this to something like /(app|config|engines|lib)/
        attr_accessor :app_dirs_pattern
    Severity: Minor
    Found in sentry-raven/lib/raven/configuration.rb - About 4 hrs to fix

      Class Scope has 33 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Scope
          include ArgumentCheckingHelper
      
          ATTRIBUTES = [
            :transaction_names,
      Severity: Minor
      Found in sentry-ruby/lib/sentry/scope.rb - About 4 hrs to fix

        File configuration.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "concurrent/utility/processor_counter"
        
        require "sentry/utils/exception_cause_chain"
        require 'sentry/utils/custom_inspection'
        require "sentry/dsn"
        Severity: Minor
        Found in sentry-ruby/lib/sentry/configuration.rb - About 4 hrs to fix

          File configuration.rb has 338 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'uri'
          
          module Raven
            class Configuration
              # Directories to be recognized as part of your app. e.g. if you
          Severity: Minor
          Found in sentry-raven/lib/raven/configuration.rb - About 4 hrs to fix

            Method set_initial_sample_decision has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_initial_sample_decision(sampling_context:)
                  unless @tracing_enabled
                    @sampled = false
                    return
                  end
            Severity: Minor
            Found in sentry-ruby/lib/sentry/transaction.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

            Class Hub has 27 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Hub
                include ArgumentCheckingHelper
            
                attr_reader :last_event_id
            
            
            Severity: Minor
            Found in sentry-ruby/lib/sentry/hub.rb - About 3 hrs to fix

              Method format_headers_for_sentry has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  def format_headers_for_sentry(env_hash)
                    env_hash.each_with_object({}) do |(key, value), memo|
                      begin
                        key = key.to_s # rack env can contain symbols
                        next memo['X-Request-Id'] ||= Utils::RequestId.read_from(env_hash) if Utils::RequestId::REQUEST_ID_HEADERS.include?(key)
              Severity: Minor
              Found in sentry-raven/lib/raven/integrations/rack.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 capture_event has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  def capture_event(event, scope, hint = {})
                    return unless configuration.sending_allowed?
              
                    if event.is_a?(ErrorEvent) && !configuration.sample_allowed?
                      transport.record_lost_event(:sample_rate, 'event')
              Severity: Minor
              Found in sentry-ruby/lib/sentry/client.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 to_hash has 72 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def to_hash
                    unless @sampled
                      record_lost_event(:sample_rate)
                      return {}
                    end
              Severity: Major
              Found in sentry-ruby/lib/sentry/profiler.rb - About 2 hrs to fix

                Method to_hash has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def to_hash
                      unless @sampled
                        record_lost_event(:sample_rate)
                        return {}
                      end
                Severity: Minor
                Found in sentry-ruby/lib/sentry/profiler.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

                Function exports has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function(api) {
                  var validEnv = ['development', 'test', 'production']
                  var currentEnv = api.env()
                  var isDevelopmentEnv = api.env('development')
                  var isProductionEnv = api.env('production')
                Severity: Major
                Found in sentry-rails/examples/rails-6.0/babel.config.js - About 2 hrs to fix

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

                      def process(value)
                        case value
                        when Hash
                          !value.frozen? ? value.merge!(value) { |_, v| process v } : value.merge(value) { |_, v| process v }
                        when Array
                  Severity: Minor
                  Found in sentry-raven/lib/raven/processor/utf8conversion.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

                  File sentry-ruby.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "English"
                  require "forwardable"
                  require "time"
                  
                  require "sentry/version"
                  Severity: Minor
                  Found in sentry-ruby/lib/sentry-ruby.rb - About 2 hrs to fix

                    Method send_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def send_data(data)
                          encoding = ""
                    
                          if should_compress?(data)
                            data = Zlib.gzip(data)
                    Severity: Minor
                    Found in sentry-ruby/lib/sentry/transport/http_transport.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 Event has 21 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                      class Event
                        # See Sentry server default limits at
                        # https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py
                        MAX_MESSAGE_SIZE_IN_BYTES = 1024 * 8
                        REQUIRED_OPTION_KEYS = [:configuration, :context, :breadcrumbs].freeze
                    Severity: Minor
                    Found in sentry-raven/lib/raven/event.rb - About 2 hrs to fix

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

                          def filter_and_format_headers(env, send_default_pii)
                            env.each_with_object({}) do |(key, value), memo|
                              begin
                                key = key.to_s # rack env can contain symbols
                                next memo['X-Request-Id'] ||= Utils::RequestId.read_from(env) if Utils::RequestId::REQUEST_ID_HEADERS.include?(key)
                      Severity: Minor
                      Found in sentry-ruby/lib/sentry/interfaces/request.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 initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def initialize(scope, env = nil)
                            @scope = scope
                            @parent_span_id = nil
                            @parent_sampled = nil
                            @baggage = nil
                      Severity: Minor
                      Found in sentry-ruby/lib/sentry/propagation_context.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 send_event has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def send_event(event, hint = nil)
                            event_type = event.is_a?(Event) ? event.type : event["type"]
                      
                            if event_type != TransactionEvent::TYPE && configuration.before_send
                              event = configuration.before_send.call(event, hint)
                      Severity: Minor
                      Found in sentry-ruby/lib/sentry/client.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

                      Severity
                      Category
                      Status
                      Source
                      Language