travis-ci/job-board

View on GitHub
lib/job_board/job_queue.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

    def claim(processor: '')
      raise Invalid, 'missing processor name' if processor.empty?

      claimed = nil

Severity: Minor
Found in lib/job_board/job_queue.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 for_queue has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.for_queue(redis: nil, site: '', queue_name: '')
      redis ||= JobBoard.redis
      raise Invalid, 'unknown queue' unless redis.sismember("queues:#{site}", queue_name)

      claims = nil
Severity: Minor
Found in lib/job_board/job_queue.rb - About 1 hr to fix

    Empty line detected around arguments.
    Open

    
          result.fetch(0) == 'OK' &&
    Severity: Minor
    Found in lib/job_board/job_queue.rb by rubocop

    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

    
          result = redis.multi do |conn|
    Severity: Minor
    Found in lib/job_board/job_queue.rb by rubocop

    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

    
          job_id = job_id.to_s.strip
    Severity: Minor
    Found in lib/job_board/job_queue.rb by rubocop

    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