getsentry/raven-ruby

View on GitHub

Showing 109 of 144 total issues

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 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 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 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 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 record has 26 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 envelope_from_event has 26 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 record has 26 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 is_rate_limited? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def is_rate_limited?(item_type)
                  # check category-specific limit
                  category_delay =
                    case item_type
                    when "transaction"
            Severity: Minor
            Found in sentry-ruby/lib/sentry/transport.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 retry_limit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def retry_limit(context, sidekiq_config)
                    limit = context.dig(:job, "retry")
            
                    case limit
                    when Integer
            Severity: Minor
            Found in sentry-sidekiq/lib/sentry/sidekiq/error_handler.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 filename has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def filename
                    return if abs_path.nil?
                    return @filename if instance_variable_defined?(:@filename)
            
                    prefix =
            Severity: Minor
            Found in sentry-raven/lib/raven/interfaces/stack_trace.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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call(ex, context, sidekiq_config = nil)
                    return unless Sentry.initialized?
            
                    context_filter = Sentry::Sidekiq::ContextFilter.new(context)
            
            
            Severity: Minor
            Found in sentry-sidekiq/lib/sentry/sidekiq/error_handler.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 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 parse_rate_limit_header has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_rate_limit_header(rate_limit_header)
                  time = Time.now
            
                  result = {}
            
            
            Severity: Minor
            Found in sentry-ruby/lib/sentry/transport/http_transport.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_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def to_hash(*args)
                    data = super(*args)
                    data.delete(:vars) unless vars && !vars.empty?
                    data.delete(:pre_context) unless pre_context && !pre_context.empty?
                    data.delete(:post_context) unless post_context && !post_context.empty?
            Severity: Minor
            Found in sentry-ruby/lib/sentry/interfaces/stacktrace.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 capture_event has a Cognitive Complexity of 9 (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 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_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def to_hash(*args)
                    data = super(*args)
                    data[:filename] = filename
                    data.delete(:vars) unless vars && !vars.empty?
                    data.delete(:pre_context) unless pre_context && !pre_context.empty?
            Severity: Minor
            Found in sentry-raven/lib/raven/interfaces/stack_trace.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 server= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def server=(value)
                  return if value.nil?
            
                  @dsn = value
            
            
            Severity: Minor
            Found in sentry-raven/lib/raven/configuration.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