Showing 64 of 133 total issues
Method validate_each
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
if value.present? && value.respond_to?(:each)
value.each do |metric|
unless metric_valid?(metric)
record.errors.add(attribute,(message || "contains an invalid metric: #{metric}"))
- 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 exec_process
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def exec_process(expr = "", namespace = {}.to_json, immediate=false)
logger.debug "#{self} exec_process"
# create script template
script_text = self.monitor_script % {utilities: self.utilities_script, expression: expr, timeout: Rearview.config.sandbox_timeout, namespace: namespace}
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def run
logger.debug "#{self} run"
validator = Rearview::MetricsValidator.new({ attributes: [:metrics], cache: true })
ActiveRecord::Base.connection_pool.with_connection do
Rearview::Job.schedulable.load.each do |job|
- 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 alert
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def alert(job, result)
job.alert_keys.each do |key|
params = PagerDutyAlert.params(key)
if PagerDutyAlert.key?(params)
logger.info "#{self} send alert for #{job.inspect} and key #{key} with params #{params}"
- 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"