getsentry/raven-ruby

View on GitHub

Showing 119 of 156 total issues

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 set_initial_sample_decision has 47 lines of code (exceeds 25 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 1 hr to fix

    Method initialize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize
          self.app_dirs_pattern = APP_DIRS_PATTERN
          self.debug = Sentry::Utils::EnvHelper.env_to_bool(ENV["SENTRY_DEBUG"])
          self.background_worker_threads = (processor_count / 2.0).ceil
          self.background_worker_max_queue = BackgroundWorker::DEFAULT_MAX_QUEUE
    Severity: Minor
    Found in sentry-ruby/lib/sentry/configuration.rb - About 1 hr to fix

      Method call has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def call(env)
              return @app.call(env) unless Sentry.initialized?
      
              # make sure the current thread has a clean hub
              Sentry.clone_hub_to_current_thread
      Severity: Minor
      Found in sentry-ruby/lib/sentry/rack/capture_exceptions.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 process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def process(value, visited = [])
            return ELISION_STRING if visited.include?(value.__id__)
      
            visited << value.__id__ if value.is_a?(Array) || value.is_a?(Hash)
      
      
      Severity: Minor
      Found in sentry-raven/lib/raven/processor/removecircularreferences.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 subscribe! has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def subscribe!
                  record_query_source = SUPPORT_SOURCE_LOCATION && Sentry.configuration.rails.enable_db_query_source
                  query_source_threshold = Sentry.configuration.rails.db_query_source_threshold_ms
      
                  subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
      Severity: Minor
      Found in sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb - About 1 hr to fix

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

            def self.from_incoming_header(header)
              items = {}
              mutable = true
        
              header.split(",").each do |item|
        Severity: Minor
        Found in sentry-ruby/lib/sentry/baggage.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 capture_type has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def capture_type(obj, options = {})
              unless configuration.capture_allowed?(obj)
                logger.debug("#{obj} excluded from capture: #{configuration.error_messages}")
                return false
              end
        Severity: Minor
        Found in sentry-raven/lib/raven/instance.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_breadcrumb has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_breadcrumb(severity, message = nil, progname = nil)
                # because the breadcrumbs now belongs to different Hub's Scope in different threads
                # we need to make sure the current thread's Hub has been set before adding breadcrumbs
                return unless Sentry.initialized? && Sentry.get_current_hub
        
        
        Severity: Minor
        Found in sentry-ruby/lib/sentry/breadcrumb/sentry_logger.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 record has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                def record(queue, worker, payload, &block)
                  Sentry.with_scope do |scope|
                    begin
                      contexts = generate_contexts(queue, worker, payload)
                      scope.set_contexts(**contexts)
        Severity: Minor
        Found in sentry-resque/lib/sentry/resque.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 capture_event has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def capture_event(event, **options, &block)
              check_argument_type!(event, Sentry::Event)
        
              return unless current_client
        
        
        Severity: Minor
        Found in sentry-ruby/lib/sentry/hub.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_sentry_sdk? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def from_sentry_sdk?(otel_span)
                dsn = Sentry.configuration.dsn
                return false unless dsn
        
                if otel_span.name.start_with?("HTTP") || otel_span.name == "connect"
        Severity: Minor
        Found in sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.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 test has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.test(dsn = nil, silent = false, config = nil)
              config ||= Raven.configuration
        
              config.logger = if silent
                                ::Logger.new(nil)
        Severity: Minor
        Found in sentry-raven/lib/raven/cli.rb - About 1 hr to fix

          Method new_job has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def new_job(name, interval_type, config, schedule, options)
                  # Schedule the job upstream first
                  # SidekiqScheduler does not validate schedules
                  # It will fail with an error if the schedule in the config is invalid.
                  # If this errors out, let it fall through.
          Severity: Minor
          Found in sentry-sidekiq/lib/sentry/sidekiq-scheduler/scheduler.rb - About 1 hr to fix

            Method capture_event has 33 lines of code (exceeds 25 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, "error")
            Severity: Minor
            Found in sentry-ruby/lib/sentry/client.rb - About 1 hr to fix

              Method send_event has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def send_event(event, hint = nil)
                    event_type = event.is_a?(Event) ? event.type : event["type"]
                    data_category = Envelope::Item.data_category(event_type)
                    spans_before = event.is_a?(TransactionEvent) ? event.spans.size : 0
              
              
              Severity: Minor
              Found in sentry-ruby/lib/sentry/client.rb - About 1 hr to fix

                Method initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def initialize
                      self.async = false
                      self.breadcrumbs_logger = []
                      self.context_lines = 3
                      self.current_environment = current_environment_from_env
                Severity: Minor
                Found in sentry-raven/lib/raven/configuration.rb - About 1 hr to fix

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

                        def compute_filename(abs_path, in_app)
                          return nil if abs_path.nil?
                  
                          under_project_root = @project_root && abs_path.start_with?(@project_root)
                  
                  
                  Severity: Minor
                  Found in sentry-ruby/lib/sentry/profiler/helpers.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 timing has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def timing(key, unit: "second", tags: {}, timestamp: nil, &block)
                          return unless block_given?
                          return yield unless DURATION_UNITS.include?(unit)
                  
                          result, value = Sentry.with_child_span(op: OP_NAME, description: key, origin: SPAN_ORIGIN) do |span|
                  Severity: Minor
                  Found in sentry-ruby/lib/sentry/metrics.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