Showing 16 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)
                        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 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 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 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 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

                      Severity
                      Category
                      Status
                      Source
                      Language