Showing 3 of 3 total issues
Method normalize_item
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def normalize_item(item)
fail(ArgumentError, 'Message must be a Hash') unless item.is_a?(Hash)
fail(ArgumentError, "Message must include a class and set of arguments: #{item.inspect}") if !item[:class] || !item[:args]
fail(ArgumentError, 'Message args must be an Array') if item[:args] && !item[:args].is_a?(Array)
fail(ArgumentError, 'Message class must be a String representation of the class name') unless item[:class].is_a?(String)
- 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 push_many
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def push_many(items)
# we're expecting items to have an nested array of args, lets take each one and correctly normalize them
payloads = items[:args].map do |args|
fail ArgumentError, "Bulk arguments must be an Array of Arrays: [[:foo => 'bar'], [:foo => 'foo']]" unless args.is_a?(Array)
# clone the original items (for :queue, :class, etc..)
- 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 push
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def push(items)
fail(ArgumentError, 'Message must be a Hash') unless items.is_a?(Hash)
fail(ArgumentError, 'Message args must be an Array') if items[:args] && !items[:args].is_a?(Array)
# args are optional
- 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"