appsignal/appsignal

View on GitHub
lib/appsignal/config.rb

Summary

Maintainability
C
1 day
Test Coverage

File config.rb has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "erb"
require "yaml"
require "uri"
require "socket"
require "tmpdir"
Severity: Minor
Found in lib/appsignal/config.rb - About 2 hrs to fix

    Method load_from_environment has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def load_from_environment
          config = {}
    
          # Configuration with string type
          %w[APPSIGNAL_PUSH_API_KEY APPSIGNAL_APP_NAME APPSIGNAL_PUSH_API_ENDPOINT
    Severity: Minor
    Found in lib/appsignal/config.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 maintain_backwards_compatibility has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def maintain_backwards_compatibility(configuration)
          configuration.tap do |config|
            DEPRECATED_CONFIG_KEY_MAPPING.each do |old_key, new_key|
              old_config_value = config.delete(old_key)
              next unless old_config_value
    Severity: Minor
    Found in lib/appsignal/config.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 load_from_environment has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def load_from_environment
          config = {}
    
          # Configuration with string type
          %w[APPSIGNAL_PUSH_API_KEY APPSIGNAL_APP_NAME APPSIGNAL_PUSH_API_ENDPOINT
    Severity: Minor
    Found in lib/appsignal/config.rb - About 1 hr to fix

      Method write_to_environment has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def write_to_environment # rubocop:disable Metrics/AbcSize
            ENV["_APPSIGNAL_ACTIVE"]                       = active?.to_s
            ENV["_APPSIGNAL_APP_PATH"]                     = root_path.to_s
            ENV["_APPSIGNAL_AGENT_PATH"]                   = File.expand_path("../../../ext", __FILE__).to_s
            ENV["_APPSIGNAL_ENVIRONMENT"]                  = env
      Severity: Minor
      Found in lib/appsignal/config.rb - About 1 hr to fix

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

            def load_from_disk
              return if !config_file || !File.exist?(config_file)
        
              configurations = YAML.load(ERB.new(IO.read(config_file)).result)
              config_for_this_env = configurations[env]
        Severity: Minor
        Found in lib/appsignal/config.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 detect_from_system has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def detect_from_system
              {}.tap do |hash|
                hash[:log] = "stdout" if Appsignal::System.heroku?
        
                # Make AppSignal active by default if APPSIGNAL_PUSH_API_KEY
        Severity: Minor
        Found in lib/appsignal/config.rb - About 25 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

        There are no issues that match your filters.

        Category
        Status