app/jobs/auth_lookup_update_job.rb
Method add_items_to_queue
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.add_items_to_queue items, t=5.seconds.from_now, priority=0, queuepriority=priority
if Seek::Config.auth_lookup_enabled
items = [items] if items.nil?
items = Array(items)
- 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 process_queue
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def process_queue
#including item_type in the order, encourages assets to be processed before users (since they are much quicker), due to tha happy coincidence
#that User falls last alphabetically. Its not that important if a new authorized type is added after User in the future.
todo = AuthLookupUpdateQueue.order("priority,item_type,id").limit(BATCHSIZE).collect do |queued|
todo = queued.item
- 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"