travis-ci/job-board

View on GitHub
lib/job_board/job_queue_reconciler.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method reclaim_for_queue has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private def reclaim_for_queue(redis: nil, site: '', queue_name: '',
                                  cutoff_seconds: 120)
      reclaimed_for_queue = []
      claimed_by_id = redis.hgetall("queue:#{site}:#{queue_name}:claims")
      claimed_by_processor = {}
Severity: Minor
Found in lib/job_board/job_queue_reconciler.rb - About 1 hr to fix

    Method reconcile! has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def reconcile!(with_ids: JobBoard.config.reconcile_stats_with_ids,
                       purge_unknown: false,
                       cutoff_seconds: JobBoard.config.reconcile_cutoff_seconds)
          JobBoard.logger.info('starting reconciliation process')
          start_time = Time.now
    Severity: Minor
    Found in lib/job_board/job_queue_reconciler.rb - About 1 hr to fix

      Method reconcile! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def reconcile!(with_ids: JobBoard.config.reconcile_stats_with_ids,
                         purge_unknown: false,
                         cutoff_seconds: JobBoard.config.reconcile_cutoff_seconds)
            JobBoard.logger.info('starting reconciliation process')
            start_time = Time.now
      Severity: Minor
      Found in lib/job_board/job_queue_reconciler.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 reclaim_for_queue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private def reclaim_for_queue(redis: nil, site: '', queue_name: '',
                                        cutoff_seconds: 120)
            reclaimed_for_queue = []
            claimed_by_id = redis.hgetall("queue:#{site}:#{queue_name}:claims")
            claimed_by_processor = {}
      Severity: Minor
      Found in lib/job_board/job_queue_reconciler.rb - About 35 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

      Use each_value instead of each.
      Open

                claimed.each do |_, claimed_for_queue|

      This cop checks for uses of each_key and each_value Hash methods.

      Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

      Example:

      # bad
      hash.keys.each { |k| p k }
      hash.values.each { |v| p v }
      hash.each { |k, _v| p k }
      hash.each { |_k, v| p v }
      
      # good
      hash.each_key { |k| p k }
      hash.each_value { |v| p v }

      Empty line detected around arguments.
      Open

      
              queue_reclaimed, queue_claimed = reclaim_for_queue(

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
              redis.scan_each(

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
              claimed_job_ids = redis.hkeys("queue:#{site}:#{queue_name}:claims")

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            unless reclaimed_for_queue.empty?

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            redis.smembers("queues:#{site}").sort.each do |queue_name|

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
              queue_def = {

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            unknown_by_queue.each do |queue_name, job_ids|

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            now = Time.now.utc

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            redis.smembers("queues:#{site}").sort.each do |queue_name|

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
              queue_capacity = 0

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
              unknown_by_queue[queue_name] ||= []

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            claimed_by_processor.reject! { |_, v| v.empty? }

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            redis.smembers("queues:#{site}").sort.each do |queue_name|

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            total

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
              measured << queue_def.merge(

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            redis.smembers("queues:#{site}").sort.each do |queue_name|

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            [reclaimed, claimed]

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            measured

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      Empty line detected around arguments.
      Open

      
            unknown_by_queue = {}

      This cops checks if empty lines exist around the arguments of a method invocation.

      Example:

      # bad
      do_something(
        foo
      
      )
      
      process(bar,
      
              baz: qux,
              thud: fred)
      
      some_method(
      
        [1,2,3],
        x: y
      )
      
      # good
      do_something(
        foo
      )
      
      process(bar,
              baz: qux,
              thud: fred)
      
      some_method(
        [1,2,3],
        x: y
      )

      There are no issues that match your filters.

      Category
      Status