mperham/sidekiq

View on GitHub
lib/sidekiq/api.rb

Summary

Maintainability
D
2 days
Test Coverage
A
97%

File api.rb has 665 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "sidekiq"

require "zlib"
require "base64"

Severity: Major
Found in lib/sidekiq/api.rb - About 1 day to fix

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

        def fetch_stats!
          pipe1_res = Sidekiq.redis { |conn|
            conn.pipelined do
              conn.get("stat:processed")
              conn.get("stat:failed")
    Severity: Minor
    Found in lib/sidekiq/api.rb - About 1 hr to fix

      Method delete_by_jid has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete_by_jid(score, jid)
            Sidekiq.redis do |conn|
              elements = conn.zrangebyscore(name, score, score)
              elements.each do |element|
                if element.index(jid)
      Severity: Minor
      Found in lib/sidekiq/api.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 remove_job has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove_job
            Sidekiq.redis do |conn|
              results = conn.multi {
                conn.zrangebyscore(parent.name, score, score)
                conn.zremrangebyscore(parent.name, score, score)
      Severity: Minor
      Found in lib/sidekiq/api.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

      There are no issues that match your filters.

      Category
      Status