getsentry/raven-ruby

View on GitHub

Showing 143 of 143 total issues

Method init has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def init(&block)
      config = Configuration.new
      yield(config) if block_given?
      config.detect_release
      apply_patches(config)
Severity: Minor
Found in sentry-ruby/lib/sentry-ruby.rb - About 45 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 send_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def send_event(event, hint = nil)
      return false unless configuration.sending_allowed?(event)

      event = configuration.before_send.call(event, hint) if configuration.before_send
      if event.nil?
Severity: Minor
Found in sentry-raven/lib/raven/client.rb - About 45 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 compute_filename has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def compute_filename
        return if abs_path.nil?

        prefix =
          if under_project_root? && in_app
Severity: Minor
Found in sentry-ruby/lib/sentry/interfaces/stacktrace.rb - About 45 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 is_rate_limited? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def is_rate_limited?(data_category)
      # check category-specific limit
      category_delay = @rate_limits[data_category]
      # check universal limit if not category limit
      universal_delay = @rate_limits[nil]
Severity: Minor
Found in sentry-ruby/lib/sentry/transport.rb - About 45 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 register_patch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def register_patch(key, patch = nil, target = nil, &block)
      if patch && block
        raise ArgumentError.new("Please provide either a patch and its target OR a block, but not both")
      end

Severity: Minor
Found in sentry-ruby/lib/sentry-ruby.rb - About 45 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_span_description has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_span_description(otel_span)
        op = otel_span.name
        description = otel_span.name

        if (http_method = otel_span.attributes[SEMANTIC_CONVENTIONS::HTTP_METHOD])
Severity: Minor
Found in sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.rb - About 45 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 finish has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def finish(hub: nil, end_timestamp: nil)
      if hub
        log_warn(
          <<~MSG
            Specifying a different hub in `Transaction#finish` will be deprecated in version 5.0.
Severity: Minor
Found in sentry-ruby/lib/sentry/transaction.rb - About 45 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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

module Sentry
  module Sidekiq
    extend Sentry::Integrable

    register_integration name: "sidekiq", version: Sentry::Sidekiq::VERSION
Severity: Major
Found in sentry-sidekiq/lib/sentry-sidekiq.rb and 2 other locations - About 40 mins to fix
sentry-delayed_job/lib/sentry-delayed_job.rb on lines 8..19
sentry-resque/lib/sentry-resque.rb on lines 8..19

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 38.

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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

module Sentry
  module DelayedJob
    extend Sentry::Integrable

    register_integration name: "delayed_job", version: Sentry::DelayedJob::VERSION
Severity: Major
Found in sentry-delayed_job/lib/sentry-delayed_job.rb and 2 other locations - About 40 mins to fix
sentry-resque/lib/sentry-resque.rb on lines 8..19
sentry-sidekiq/lib/sentry-sidekiq.rb on lines 9..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 38.

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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

module Sentry
  module Resque
    extend Sentry::Integrable

    register_integration name: "resque", version: Sentry::Resque::VERSION
Severity: Major
Found in sentry-resque/lib/sentry-resque.rb and 2 other locations - About 40 mins to fix
sentry-delayed_job/lib/sentry-delayed_job.rb on lines 8..19
sentry-sidekiq/lib/sentry-sidekiq.rb on lines 9..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 38.

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

        def add(name, started, _finished, _unique_id, data)
Severity: Minor
Found in sentry-raven/lib/raven/breadcrumbs/active_support_logger.rb - About 35 mins to fix

    Method add has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

              def add(name, started, _finished, _unique_id, data)
    Severity: Minor
    Found in sentry-rails/lib/sentry/rails/breadcrumb/active_support_logger.rb - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(file, number, method, module_name, in_app_pattern)
      Severity: Minor
      Found in sentry-ruby/lib/sentry/backtrace.rb - About 35 mins to fix

        Method add has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                  def add(name, started, _finished, _unique_id, data)

          Method new_job has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def new_job(name, interval_type, config, schedule, options)
          Severity: Minor
          Found in sentry-sidekiq/lib/sentry/sidekiq-scheduler/scheduler.rb - About 35 mins to fix

            Method from_exception has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.from_exception(exc, options = {}, &block)
                  exception_context = if exc.instance_variable_defined?(:@__raven_context)
                                        exc.instance_variable_get(:@__raven_context)
                                      elsif exc.respond_to?(:raven_context)
                                        exc.raven_context
            Severity: Minor
            Found in sentry-raven/lib/raven/event.rb - About 35 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 send_event has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def send_event(auth_header, data, options = {})
                    unless configuration.sending_allowed?
                      configuration.logger.debug("Event not sent: #{configuration.error_messages}")
                      return
                    end
            Severity: Minor
            Found in sentry-raven/lib/raven/transports/http.rb - About 35 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 rack_env= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def rack_env=(env)
                  unless request || env.empty?
                    add_request_interface(env)
            
                    if @send_default_pii
            Severity: Minor
            Found in sentry-ruby/lib/sentry/event.rb - About 35 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 valid? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def valid?
                  return true if %w(server host path public_key project_id).all? { |k| public_send(k) }
            
                  if server
                    %w(server host path public_key project_id).map do |key|
            Severity: Minor
            Found in sentry-raven/lib/raven/configuration.rb - About 35 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 record has a Cognitive Complexity of 7 (exceeds 5 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 35 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