appsignal/appsignal

View on GitHub
lib/appsignal/transaction.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Transaction has 42 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Transaction
    HTTP_REQUEST   = "http_request".freeze
    BACKGROUND_JOB = "background_job".freeze
    ACTION_CABLE   = "action_cable".freeze
    FRONTEND       = "frontend".freeze
Severity: Minor
Found in lib/appsignal/transaction.rb - About 5 hrs to fix

    File transaction.rb has 316 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "json"
    
    module Appsignal
      class Transaction
        HTTP_REQUEST   = "http_request".freeze
    Severity: Minor
    Found in lib/appsignal/transaction.rb - About 3 hrs to fix

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

          def http_queue_start
            env = environment
            return unless env
            env_var = env["HTTP_X_QUEUE_START".freeze] || env["HTTP_X_REQUEST_START".freeze]
            return unless env_var
      Severity: Minor
      Found in lib/appsignal/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 set_sample_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_sample_data(key, data)
            return unless key && data && (data.is_a?(Array) || data.is_a?(Hash))
            @ext.set_sample_data(
              key.to_s,
              Appsignal::Utils::Data.generate(data)
      Severity: Minor
      Found in lib/appsignal/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

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

          def set_error(error)
            unless error.is_a?(Exception)
              Appsignal.logger.error "Appsignal::Transaction#set_error: Cannot set error. " \
                "The given value is not an exception: #{error.inspect}"
              return
      Severity: Minor
      Found in lib/appsignal/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

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

          def record_event(name, title, body, duration, body_format = Appsignal::EventFormatter::DEFAULT)
      Severity: Minor
      Found in lib/appsignal/transaction.rb - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status