getsentry/raven-ruby

View on GitHub

Showing 143 of 143 total issues

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 apply_to_event has a Cognitive Complexity of 15 (exceeds 5 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

    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 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 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 initialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize
            self.app_dirs_pattern = nil
            self.debug = false
            self.background_worker_threads = Concurrent.processor_count
            self.background_worker_max_queue = BackgroundWorker::DEFAULT_MAX_QUEUE
      Severity: Minor
      Found in sentry-ruby/lib/sentry/configuration.rb - About 1 hr to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        Rails.application.routes.draw do
          resources :posts
          get '500', to: 'welcome#report_demo'
          root to: "welcome#index"
        
        
        Severity: Major
        Found in sentry-rails/examples/rails-7.0/config/routes.rb and 1 other location - About 1 hr to fix
        sentry-rails/examples/rails-6.0/config/routes.rb on lines 3..20

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 66.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        Rails.application.routes.draw do
          resources :posts
          get '500', to: 'welcome#report_demo'
          root to: "welcome#index"
        
        
        Severity: Major
        Found in sentry-rails/examples/rails-6.0/config/routes.rb and 1 other location - About 1 hr to fix
        sentry-rails/examples/rails-7.0/config/routes.rb on lines 3..20

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 66.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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 request has a Cognitive Complexity of 13 (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) 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 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 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 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 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 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 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

              Severity
              Category
              Status
              Source
              Language