Showing 76 of 84 total issues
Method install
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def install
library_type = "static"
report["language"]["implementation"] = "ruby"
report["build"]["library_type"] = library_type
return unless check_architecture
Method start
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start
unless extension_loaded?
logger.info("Not starting appsignal, extension is not loaded")
return
end
Method report
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def report
@report ||=
begin
rbconfig = RbConfig::CONFIG
{
Method download_archive
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def download_archive(type)
report["build"]["source"] = "remote"
unless ARCH_CONFIG.key?(type)
abort_installation(
Method paths
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def paths
@paths ||=
begin
config = Appsignal.config
log_file_path = config.log_file_path
Method included
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.class_eval do
def _run_with_appsignal(*)
local_attrs = respond_to?(:que_attrs) ? que_attrs : attrs
env = {
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
- Read upRead up
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_with_appsignal_monitoring
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call_with_appsignal_monitoring(env)
request = ::Rack::Request.new(env)
transaction = Appsignal::Transaction.create(
SecureRandom.uuid,
Appsignal::Transaction::HTTP_REQUEST,
Method monitor_transaction
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def monitor_transaction(name, env = {})
# Always verify input, even when Appsignal is not active.
# This makes it more likely invalid arguments get flagged in test/dev
# environments.
if name.start_with?("perform_job".freeze)
Method invoke_with_instrumentation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.invoke_with_instrumentation(job, block)
payload = job.payload_object
if payload.respond_to? :job_data
# ActiveJob
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
Method map_hash
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def map_hash(hash_value)
map = Appsignal::Extension.data_map_new
hash_value.each do |key, value|
key = key.to_s
case value
Method parse_arguments
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_arguments(job)
args = job.fetch("args", [])
case job["class"]
when /\ASidekiq::Extensions::Delayed/
safe_load(args[0], args) do |_, _, arg|
- Read upRead up
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_with_appsignal_monitoring
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def call_with_appsignal_monitoring(env)
request = ::Rack::Request.new(env)
transaction = Appsignal::Transaction.create(
SecureRandom.uuid,
Appsignal::Transaction::HTTP_REQUEST,
- Read upRead up
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 run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def run(push_api_key, options) # rubocop:disable Metrics/AbcSize
self.coloring = options.delete(:color) { true }
$stdout.sync = true
puts
- Read upRead up
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 map_array
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def map_array(array_value)
array = Appsignal::Extension.data_array_new
array_value.each do |value|
case value
when String
Method run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(argv = ARGV)
@options = {}
global = global_option_parser
commands = command_option_parser
global.order!(argv)
Method call_with_appsignal_monitoring
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call_with_appsignal_monitoring(env)
if @options[:params_method]
env[:params_method] = @options[:params_method]
end
request = @options.fetch(:request_class, Sinatra::Request).new(env)
Method parse_arguments
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_arguments(job)
args = job.fetch("args", [])
case job["class"]
when /\ASidekiq::Extensions::Delayed/
safe_load(args[0], args) do |_, _, arg|
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