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
Severity: Minor
Found in lib/qyu/models/concerns/workflow_descriptor_validator.rb - About 5 hrs to fix

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
Severity: Minor
Found in lib/qyu/models/task.rb - About 3 hrs to fix

    Class Adapter has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class Adapter < Qyu::Store::Base
            TYPE = :memory
    
            def initialize(_config)
              @workflows = {}
    Severity: Minor
    Found in lib/qyu/store/memory/adapter.rb - About 2 hrs to fix

      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
      Severity: Minor
      Found in lib/qyu/store/base.rb - About 2 hrs to fix

        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
        Severity: Minor
        Found in lib/qyu/workers/base.rb - About 2 hrs to fix

        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
        
        
        Severity: Minor
        Found in lib/qyu/models/job.rb - About 2 hrs to fix

          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|
          Severity: Minor
          Found in lib/qyu/workers/concerns/payload_validator.rb - About 2 hrs to fix

          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
          Severity: Minor
          Found in lib/qyu/workers/base.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/qyu/models/concerns/workflow_descriptor_validator.rb - About 1 hr to fix

              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
              Severity: Minor
              Found in examples/split_n_sync/workers/split_array_worker_with_block.rb - About 1 hr to fix

                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}")
                Severity: Minor
                Found in lib/qyu/workers/sync.rb - About 45 mins to fix

                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?
                Severity: Minor
                Found in lib/qyu/workers/split.rb - About 45 mins to fix

                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)
                Severity: Minor
                Found in lib/qyu/store/memory/adapter.rb - About 35 mins to fix

                  Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def initialize(id, workflow, payload, created_at = nil, updated_at = nil)
                  Severity: Minor
                  Found in lib/qyu/models/job.rb - About 35 mins to fix

                    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def initialize(id, name, descriptor, created_at = nil, updated_at = nil)
                    Severity: Minor
                    Found in lib/qyu/models/workflow.rb - About 35 mins to fix

                      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
                      Severity: Minor
                      Found in lib/qyu/models/workflow.rb - About 25 mins to fix

                      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) &&
                      Severity: Minor
                      Found in lib/qyu/models/concerns/workflow_descriptor_validator.rb and 1 other location - About 15 mins to fix
                      lib/qyu/models/concerns/workflow_descriptor_validator.rb on lines 97..103

                      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

                      Further Reading

                      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) &&
                      Severity: Minor
                      Found in lib/qyu/models/concerns/workflow_descriptor_validator.rb and 1 other location - About 15 mins to fix
                      lib/qyu/models/concerns/workflow_descriptor_validator.rb on lines 89..95

                      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

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language