getsentry/raven-ruby

View on GitHub

Showing 119 of 156 total issues

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

    def stacktrace_interface_from(backtrace)
      Backtrace.parse(backtrace, { configuration: configuration }).lines.reverse.each_with_object([]) do |line, memo|
        frame = StacktraceInterface::Frame.new
        frame.abs_path = line.file if line.file
        frame.function = line.method if line.method
Severity: Minor
Found in sentry-raven/lib/raven/event.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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add(type,
              key,
              value,
              unit: "none",
              tags: {},
Severity: Minor
Found in sentry-ruby/lib/sentry/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 handle_rate_limited_response has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_rate_limited_response(headers)
      rate_limits =
        if rate_limits = headers[RATE_LIMIT_HEADER]
          parse_rate_limit_header(rate_limits)
        elsif retry_after = headers[RETRY_AFTER_HEADER]
Severity: Minor
Found in sentry-ruby/lib/sentry/transport/http_transport.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 build_with_stacktrace has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def self.build_with_stacktrace(exception:, stacktrace_builder:, mechanism:)
      stacktrace = stacktrace_builder.build(backtrace: exception.backtrace)

      if locals = exception.instance_variable_get(:@sentry_locals)
        locals.each do |k, v|
Severity: Minor
Found in sentry-ruby/lib/sentry/interfaces/single_exception.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 envelope_from_event has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def envelope_from_event(event)
      # Convert to hash
      event_payload = event.to_hash
      event_id = event_payload[:event_id] || event_payload["event_id"]
      item_type = event_payload[:type] || event_payload["type"]
Severity: Minor
Found in sentry-ruby/lib/sentry/transport.rb - About 1 hr to fix

    Method send_data has 31 lines of code (exceeds 25 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 1 hr to fix

      Method record has 31 lines of code (exceeds 25 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

        Method record has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  def record(job, &block)
                    Sentry.with_scope do |scope|
                      begin
                        scope.set_transaction_name(job.class.name, source: :task)
                        transaction =
        Severity: Minor
        Found in sentry-rails/lib/sentry/rails/active_job.rb - About 1 hr to fix

          Method test has a Cognitive Complexity of 10 (exceeds 5 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

          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 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_breadcrumb(severity, message = nil, progname = nil)
                  message = progname if message.nil? # see Ruby's Logger docs for why
                  return if ignored_logger?(progname)
                  return if message.nil? || message == ""
          
          
          Severity: Minor
          Found in sentry-raven/lib/raven/breadcrumbs/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 stop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def stop
                  return unless @sampled
                  return unless @started
          
                  @result = ::Vernier.stop_profile
          Severity: Minor
          Found in sentry-ruby/lib/sentry/vernier/profiler.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 request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def request(req, body = nil, &block)
                  return super unless started? && Sentry.initialized?
                  return super if from_sentry_sdk?
          
                  Sentry.with_child_span(op: OP_NAME, start_timestamp: Sentry.utc_now.to_f, origin: SPAN_ORIGIN) do |sentry_span|
          Severity: Minor
          Found in sentry-ruby/lib/sentry/net/http.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 new_job has a Cognitive Complexity of 10 (exceeds 5 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

          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 compute_filename has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def compute_filename
                  return if abs_path.nil?
                  return abs_path unless @strip_backtrace_load_path
          
                  prefix =
          Severity: Minor
          Found in sentry-ruby/lib/sentry/interfaces/stacktrace.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 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                    def capture(connection, transaction_name:, extra_context: nil, &block)
                      return block.call unless Sentry.initialized?
                      # ActionCable's ConnectionStub (for testing) doesn't implement the exact same interfaces as Connection::Base.
                      # One thing that's missing is `env`. So calling `connection.env` direclty will fail in test environments when `stub_connection` is used.
                      # See https://github.com/getsentry/sentry-ruby/pull/1684 for more information.
          Severity: Minor
          Found in sentry-rails/lib/sentry/rails/action_cable.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(configuration)
                @shutdown_timeout = 1
                @number_of_threads = configuration.background_worker_threads
                @max_queue = configuration.background_worker_max_queue
                @logger = configuration.logger
          Severity: Minor
          Found in sentry-ruby/lib/sentry/background_worker.rb - About 1 hr to fix

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

                  def on_start(otel_span, parent_context)
                    return unless Sentry.initialized? && Sentry.configuration.instrumenter == :otel
                    return unless otel_span.context.valid?
                    return if from_sentry_sdk?(otel_span)
            
            
            Severity: Minor
            Found in sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.rb - About 1 hr to fix

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

                  def apply_to_event(event, hint = nil)
                    unless event.is_a?(CheckInEvent)
                      event.tags = tags.merge(event.tags)
                      event.user = user.merge(event.user)
                      event.extra = extra.merge(event.extra)
              Severity: Minor
              Found in sentry-ruby/lib/sentry/scope.rb - About 1 hr to fix

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

                    def self.from_sentry_trace(sentry_trace, baggage: nil, hub: Sentry.get_current_hub, **options)
                      return unless hub.configuration.tracing_enabled?
                      return unless sentry_trace
                
                      sentry_trace_data = extract_sentry_trace(sentry_trace)
                Severity: Minor
                Found in sentry-ruby/lib/sentry/transaction.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 on_finish has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def on_finish(otel_span)
                        return unless Sentry.initialized? && Sentry.configuration.instrumenter == :otel
                        return unless otel_span.context.valid?
                
                        sentry_span = @span_map.delete(otel_span.context.hex_span_id)
                Severity: Minor
                Found in sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.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

                Severity
                Category
                Status
                Source
                Language