File batch.rb
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'securerandom'
require 'sidekiq'
require 'sidekiq/batch/callback'
require 'sidekiq/batch/middleware'
Method jobs
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def jobs
raise NoBlockGivenError unless block_given?
bid_data, Thread.current[:bid_data] = Thread.current[:bid_data], []
Method jobs
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def jobs
raise NoBlockGivenError unless block_given?
bid_data, Thread.current[:bid_data] = Thread.current[:bid_data], []
- 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 enqueue_callbacks
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def enqueue_callbacks(event, bid)
event_name = event.to_s
batch_key = "BID-#{bid}"
callback_key = "#{batch_key}-callbacks-#{event_name}"
already_processed, _, callbacks, queue, parent_bid, callback_batch = Sidekiq.redis do |r|
Method enqueue_callbacks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def enqueue_callbacks(event, bid)
event_name = event.to_s
batch_key = "BID-#{bid}"
callback_key = "#{batch_key}-callbacks-#{event_name}"
already_processed, _, callbacks, queue, parent_bid, callback_batch = Sidekiq.redis do |r|
- 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 conditional_redis_increment!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def conditional_redis_increment!(force=false)
if should_increment? || force
parent_bid = Thread.current[:parent_bid]
Sidekiq.redis do |r|
r.multi do |pipeline|
- 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 should_increment?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def should_increment?
return false unless @incremental_push
return true if @batch_push_interval == 0 || @queued_jids.length == 1
now = Time.now.to_f
@last_increment ||= now
- 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"