mhenrixon/sidekiq-unique-jobs

View on GitHub
lib/sidekiq_unique_jobs/locksmith.rb

Summary

Maintainability
A
3 hrs
Test Coverage
A
98%

Class Locksmith has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Locksmith # rubocop:disable Metrics/ClassLength
    # includes "SidekiqUniqueJobs::Connection"
    # @!parse include SidekiqUniqueJobs::Connection
    include SidekiqUniqueJobs::Connection

Severity: Minor
Found in lib/sidekiq_unique_jobs/locksmith.rb - About 3 hrs to fix

Complex method SidekiqUniqueJobs::Locksmith#enqueue (26.6)
Open

    def enqueue(conn)
      queued_jid, elapsed = timed do
        call_script(:queue, key.to_a, argv, conn)
      end

Severity: Minor
Found in lib/sidekiq_unique_jobs/locksmith.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method SidekiqUniqueJobs::Locksmith#lock_info (23.0)
Open

    def lock_info
      @lock_info ||= dump_json(
        WORKER => item[CLASS],
        QUEUE => item[QUEUE],
        LIMIT => item[LOCK_LIMIT],
Severity: Minor
Found in lib/sidekiq_unique_jobs/locksmith.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Method enqueue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def enqueue(conn)
      queued_jid, elapsed = timed do
        call_script(:queue, key.to_a, argv, conn)
      end

Severity: Minor
Found in lib/sidekiq_unique_jobs/locksmith.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

Complex method SidekiqUniqueJobs::Locksmith#lock! (21.9)
Open

    def lock!(conn, primed_method, wait = nil)
      return yield if locked?(conn)

      enqueue(conn) do |queued_jid|
        reflect(:debug, :queued, item, queued_jid)
Severity: Minor
Found in lib/sidekiq_unique_jobs/locksmith.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

There are no issues that match your filters.

Category
Status