resque/resque-scheduler

View on GitHub

Showing 15 of 15 total issues

File scheduler.rb has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'redis/errors'
require 'rufus/scheduler'
require_relative 'scheduler/configuration'
require_relative 'scheduler/locking'
require_relative 'scheduler/logger_builder'
Severity: Minor
Found in lib/resque/scheduler.rb - About 5 hrs to fix

    Method load_schedule_job has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def load_schedule_job(name, config)
            # If `rails_env` or `env` is set in the config, load jobs only if they
            # are meant to be loaded in `Resque::Scheduler.env`.  If `rails_env` or
            # `env` is missing, the job should be scheduled regardless of the value
            # of `Resque::Scheduler.env`.
    Severity: Minor
    Found in lib/resque/scheduler.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 setup_scheduler_configuration has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

          def setup_scheduler_configuration
            Resque::Scheduler.configure do |c|
              c.app_name = options[:app_name] if options.key?(:app_name)
    
              c.dynamic = !!options[:dynamic] if options.key?(:dynamic)
    Severity: Minor
    Found in lib/resque/scheduler/env.rb - About 1 hr 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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def run
            procline 'Starting'
    
            # trap signals
            register_signal_handlers
    Severity: Minor
    Found in lib/resque/scheduler.rb - About 1 hr 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 enqueue_from_config has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def enqueue_from_config(job_config)
            args = job_config['args'] || job_config[:args]
    
            klass_name = job_config['class'] || job_config[:class]
            begin
    Severity: Minor
    Found in lib/resque/scheduler.rb - About 1 hr 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 enqueue_from_config has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def enqueue_from_config(job_config)
            args = job_config['args'] || job_config[:args]
    
            klass_name = job_config['class'] || job_config[:class]
            begin
    Severity: Minor
    Found in lib/resque/scheduler.rb - About 1 hr to fix

      Method run has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def run
              procline 'Starting'
      
              # trap signals
              register_signal_handlers
      Severity: Minor
      Found in lib/resque/scheduler.rb - About 1 hr to fix

        Method poll_sleep_loop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def poll_sleep_loop
                @sleeping = true
                if poll_sleep_amount > 0
                  start = Time.now
                  loop do
        Severity: Minor
        Found in lib/resque/scheduler.rb - About 1 hr 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 update_schedule has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def update_schedule
                if Resque.redis.scard(:schedules_changed) > 0
                  procline 'Updating schedule'
                  loop do
                    schedule_name = Resque.redis.spop(:schedules_changed)
        Severity: Minor
        Found in lib/resque/scheduler.rb - About 1 hr 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 enqueue_delayed_items_for_timestamp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def enqueue_delayed_items_for_timestamp(timestamp)
                count = 0
                batch_size = delayed_requeue_batch_size
                actual_batch_size = nil
        
        
        Severity: Minor
        Found in lib/resque/scheduler.rb - About 55 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 constantize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.constantize(camel_cased_word)
                camel_cased_word = camel_cased_word.to_s
        
                if camel_cased_word.include?('-')
                  camel_cased_word = classify(camel_cased_word)
        Severity: Minor
        Found in lib/resque/scheduler/util.rb - About 55 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 search_first_delayed_timestamp_in_range has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def search_first_delayed_timestamp_in_range(start_at, stop_at)
                start_at = start_at.nil? ? '-inf' : start_at.to_i
                stop_at = stop_at.nil? ? '+inf' : stop_at.to_i
        
                items = redis.zrangebyscore(
        Severity: Minor
        Found in lib/resque/scheduler/delaying_extensions.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 optionizate_interval_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def optionizate_interval_value(value)
                args = value
                if args.is_a?(::Array)
                  return args.first if args.size > 2 || !args.last.is_a?(::Hash)
                  # symbolize keys of hash for options
        Severity: Minor
        Found in lib/resque/scheduler.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 enqueue_at_with_queue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def enqueue_at_with_queue(queue, timestamp, klass, *args)
                return false unless plugin.run_before_schedule_hooks(klass, *args)
        
                if Resque.inline? || timestamp.to_i <= Time.now.to_i
                  # Just create the job and let resque perform it right away with
        Severity: Minor
        Found in lib/resque/scheduler/delaying_extensions.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 handle_signals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def handle_signals
                loop do
                  sig = signal_queue.shift
                  break unless sig
                  log! "Got #{sig} signal"
        Severity: Minor
        Found in lib/resque/scheduler/signal_handling.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