Showing 18 of 18 total issues
Method validate
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def validate
@errors << 'Descriptor type must be a Hash.' unless validate_descriptor_type
@errors << 'Entry points (starts) must be an Array.' unless validate_entry_points_type
@errors << 'Tasks must be a Hash.' unless validate_tasks_type
unless validate_entry_points_presence
- 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
Class Task
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Task
attr_reader :queue_name, :payload, :status, :id, :job_id, :name, :parent_task_id,
:message_id, :created_at, :updated_at
LEASE_PERCENTAGE_THRESHOLD_BEFORE_RENEWAL = 0.8
Class Adapter
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Adapter < Qyu::Store::Base
TYPE = :memory
def initialize(_config)
@workflows = {}
Class Base
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
# This class acts as an interface for any store implemented for Qyu
# Implement the following methods in any store and it should work seemlessly
def self.valid_config?(_config)
fail Qyu::Errors::NotImplementedError
Method work
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def work(queue_name, blocking: true)
log(:info, "worker started for queue '#{queue_name}'")
repeat = true
remaining_fetch_retries = 3
- 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
Class Job
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Job
attr_reader :descriptor, :payload, :workflow, :id, :created_at, :updated_at
## Class Methods
Method validate_payload!
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def validate_payload!(model)
return unless @_validations
payload = Qyu::Utils.stringify_hash_keys(model.payload || {})
validation_errors = {}
@_validations.each do |attribute, opts|
- 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 work
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def work(queue_name, blocking: true)
log(:info, "worker started for queue '#{queue_name}'")
repeat = true
remaining_fetch_retries = 3
Method validate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate
@errors << 'Descriptor type must be a Hash.' unless validate_descriptor_type
@errors << 'Entry points (starts) must be an Array.' unless validate_entry_points_type
@errors << 'Tasks must be a Hash.' unless validate_tasks_type
unless validate_entry_points_presence
Method run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
Qyu::SplitWorker.new do
callback :execute, :before do
Qyu.logger.info 'Waiting for task..'
end
Method work
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def work(queue_name, blocking: true)
super do |task|
job = task.job
task_names_to_wait_for = job.tasks_to_wait_for(task)
log(:debug, "Task names to wait for: #{task_names_to_wait_for}")
- 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 work
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def work(queue_name, blocking: true)
validate_split_parameters!
super do |task|
if block_given?
- 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 find_or_persist_task
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find_or_persist_task(name, queue_name, payload, job_id, parent_task_id)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(id, workflow, payload, created_at = nil, updated_at = nil)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(id, name, descriptor, created_at = nil, updated_at = nil)
Method delete_by
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def delete_by(name: nil, id: nil)
raise ArgumentError, 'specify either name or id' if (name && id) || (name.nil? && id.nil?)
Qyu.store.delete_workflow_by_name(name) if name
delete(id) if id
end
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def validate_task_reference_formats(task_name)
validate_format(task_name, 'starts', Array) &&
validate_format(task_name, 'starts_parallel', Array) &&
validate_format(task_name, 'starts_manually', Array) &&
validate_format(task_name, 'starts_with_params', Hash) &&
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 26.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def validate_referenced_tasks(task_name)
validate_presence_of_reference_tasks(task_name, 'starts', Array) &&
validate_presence_of_reference_tasks(task_name, 'starts_parallel', Array) &&
validate_presence_of_reference_tasks(task_name, 'starts_manually', Array) &&
validate_presence_of_reference_tasks(task_name, 'starts_with_params', Hash) &&
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 26.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76